cifs: implement proper hardlink handling (try #5)
cover cifs: implement proper hardlink handling (try #5)
This is the 5th attempt at a patchset to implement hardlink handling in CIFS. The main differences from the last set are:
1) consolidated some of the patches to better help bisectability
2) redefined FILE_UNIX_INFO such that it has an embedded FILE_UNIX_BASIC_INFO struct. This change makes it easier to use cifs_unix_basic_to_fattr in the readdir codepath and eliminate cifs_unix_info_to_fattr.
3) minor cleanups and fewer false deltas between patches
Aside from the unix readdir codepath changes listed above, the final result from this set is pretty close to the result of the last set. This one actually eliminates extra 100 lines or so too (mostly by changing posix readdir to use the existing to_fattr routine instead of adding a new one).
Christoph, since most of the changes here are stuff we've already discussed, I went ahead and left your Reviewed-by: tag in place on the ones that you've already reviewed. Let me know if you object to any of the changes and we'll work it out.
Christoph Hellwig (2):
cifs: reorganize get_cifs_acl
cifs: clean up set_cifs_acl interfaces
Jeff Layton (8):
cifs: have cifs_NTtimeToUnix take a little-endian arg
cifs: make cnvrtDosUnixTm take a little-endian args and an offset
cifs: rename cifs_iget to cifs_root_iget
cifs: add new cifs_iget function and convert unix codepath to use it
cifs: convert cifs_get_inode_info and non-posix readdir to use
cifs_iget
cifs: make serverino the default when mounting
cifs: remove cifsInodeInfo->inUse counter
cifs: remove "hardlink detection" from cifs_rename
fs/cifs/cifsacl.c | 200 +++++++------ fs/cifs/cifsfs.c | 3 +- fs/cifs/cifsfs.h | 15 +- fs/cifs/cifsglob.h | 28 ++- fs/cifs/cifspdu.h | 14 +- fs/cifs/cifsproto.h | 21 +- fs/cifs/cifssmb.c | 4 +- fs/cifs/connect.c | 2 + fs/cifs/dir.c | 22 +- fs/cifs/file.c | 2 +- fs/cifs/inode.c | 802 +++++++++++++++++++++------------------------------ fs/cifs/netmisc.c | 24 +- fs/cifs/readdir.c | 517 ++++++++------------------------- 13 files changed, 635 insertions(+), 1019 deletions(-)
PATCH 1/10 cifs: have cifs_NTtimeToUnix take a little-endian arg
...and just have the function call le64_to_cpu.
--- fs/cifs/cifsproto.h | 2 +- fs/cifs/file.c | 2 +- fs/cifs/inode.c | 15 ++++++--------- fs/cifs/netmisc.c | 12 ++++++------ fs/cifs/readdir.c | 12 ++++++------ 5 files changed, 20 insertions(+), 23 deletions(-)
fs/cifs/cifsproto.h +1 -1
@@ -90,7 +90,7 @@ extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16, struct cifsTconInfo *);extern void DeleteOplockQEntry (struct oplock_q_entry *);extern void DeleteTconOplockQEntries (struct cifsTconInfo *); -extern struct timespec cifs_NTtimeToUnix (u64 utc_nanoseconds_since_1601); +extern struct timespec cifs_NTtimeToUnix (__le64 utc_nanoseconds_since_1601);extern u64 cifs_UnixTimeToNT (struct timespec );extern __le64 cnvrtDosCifsTm (__u16 date,__u16 time);extern struct timespec cnvrtDosUnixTm (__u16 date,__u16 time);
fs/cifs/file.c +1 -1
@@ -241,7 +241,7 @@ static inline int cifs_open_inode_helper(struct inode *inode, struct file *file,/* BB need same check in cifs_create too? */ /* if not oplocked, invalidate inode pages if mtime or file size changed */ - temp =cifs_NTtimeToUnix (le64_to_cpu (buf->LastWriteTime)); + temp =cifs_NTtimeToUnix (buf->LastWriteTime);if (timespec_equal (&file->f_path.dentry->d_inode->i_mtime, &temp) && (file->f_path.dentry->d_inode->i_size == (loff_t )le64_to_cpu (buf->EndOfFile))) {
fs/cifs/inode.c +6 -9
@@ -85,10 +85,10 @@ static void cifs_unix_info_to_inode(struct inode *inode,__u64 num_of_bytes =le64_to_cpu (info->NumOfBytes);__u64 end_of_file =le64_to_cpu (info->EndOfFile); - inode->i_atime =cifs_NTtimeToUnix (le64_to_cpu (info->LastAccessTime)); + inode->i_atime =cifs_NTtimeToUnix (info->LastAccessTime); inode->i_mtime = -cifs_NTtimeToUnix (le64_to_cpu (info->LastModificationTime)); - inode->i_ctime =cifs_NTtimeToUnix (le64_to_cpu (info->LastStatusChange)); +cifs_NTtimeToUnix (info->LastModificationTime); + inode->i_ctime =cifs_NTtimeToUnix (info->LastStatusChange); inode->i_mode =le64_to_cpu (info->Permissions);/*
@@ -554,14 +554,11 @@ int cifs_get_inode_info(struct inode **pinode,/* Linux can not store file creation time so ignore it */ if (pfindData->LastAccessTime) - inode->i_atime =cifs_NTtimeToUnix - (le64_to_cpu (pfindData->LastAccessTime)); + inode->i_atime =cifs_NTtimeToUnix (pfindData->LastAccessTime);else /* do not need to use current_fs_time - time not stored */ inode->i_atime =CURRENT_TIME ; - inode->i_mtime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastWriteTime)); - inode->i_ctime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->ChangeTime)); + inode->i_mtime =cifs_NTtimeToUnix (pfindData->LastWriteTime); + inode->i_ctime =cifs_NTtimeToUnix (pfindData->ChangeTime);cFYI (DBG2 , ("Attributes came in as 0x%x" , attr));if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
fs/cifs/netmisc.c +6 -6
@@ -853,12 +853,12 @@ smbCalcSize_LE(struct smb_hdr *ptr)#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000) -/* -* Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) -* into Unix UTC (based 1970-01-01, in seconds). -*/ +/* +* Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) +* into Unix UTC (based 1970-01-01, in seconds). +*/ struct timespec -cifs_NTtimeToUnix (u64 ntutc) +cifs_NTtimeToUnix (__le64 ntutc) {struct timespec ts;/* BB what about the timezone? BB */
@@ -866,7 +866,7 @@ cifs_NTtimeToUnix(u64 ntutc)/* Subtract the NTFS time offset, then convert to 1s intervals. */ u64 t; - t = ntutc -NTFS_TIME_OFFSET ; + t =le64_to_cpu (ntutc) -NTFS_TIME_OFFSET ; ts.tv_nsec =do_div (t,10000000 ) *100 ; ts.tv_sec = t;return ts;
fs/cifs/readdir.c +6 -6
@@ -150,11 +150,11 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, allocation_size =le64_to_cpu (pfindData->AllocationSize); end_of_file =le64_to_cpu (pfindData->EndOfFile); tmp_inode->i_atime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastAccessTime)); +cifs_NTtimeToUnix (pfindData->LastAccessTime); tmp_inode->i_mtime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastWriteTime)); +cifs_NTtimeToUnix (pfindData->LastWriteTime); tmp_inode->i_ctime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->ChangeTime)); +cifs_NTtimeToUnix (pfindData->ChangeTime); }else {/* legacy, OS2 and DOS style */ /* struct timespec ts;*/ FIND_FILE_STANDARD_INFO *pfindData =
@@ -331,11 +331,11 @@ static void unix_fill_in_inode(struct inode *tmp_inode, local_size = tmp_inode->i_size; tmp_inode->i_atime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastAccessTime)); +cifs_NTtimeToUnix (pfindData->LastAccessTime); tmp_inode->i_mtime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastModificationTime)); +cifs_NTtimeToUnix (pfindData->LastModificationTime); tmp_inode->i_ctime = -cifs_NTtimeToUnix (le64_to_cpu (pfindData->LastStatusChange)); +cifs_NTtimeToUnix (pfindData->LastStatusChange); tmp_inode->i_mode =le64_to_cpu (pfindData->Permissions);/* since we set the inode type below we need to mask off type
Signature · 1 line
1.6.2.2
PATCH 2/10 cifs: make cnvrtDosUnixTm take a little-endian args and an offset
In reply to Jeff LaytonThe callers primarily end up converting the args from le anyway. Also, most of the callers end up needing to add an offset to the result. The exception to these rules is cnvrtDosCifsTm, but there are no callers of that function, so we might as well remove it.
--- fs/cifs/cifsproto.h | 4 ++-- fs/cifs/cifssmb.c | 4 ++-- fs/cifs/netmisc.c | 12 ++++-------- fs/cifs/readdir.c | 32 ++++++++++---------------------- 4 files changed, 18 insertions(+), 34 deletions(-)
fs/cifs/cifsproto.h +2 -2
@@ -92,8 +92,8 @@ extern void DeleteOplockQEntry(struct oplock_q_entry *);extern void DeleteTconOplockQEntries (struct cifsTconInfo *);extern struct timespec cifs_NTtimeToUnix (__le64 utc_nanoseconds_since_1601);extern u64 cifs_UnixTimeToNT (struct timespec ); -extern __le64 cnvrtDosCifsTm (__u16 date,__u16 time); -extern struct timespec cnvrtDosUnixTm (__u16 date,__u16 time); +extern struct timespec cnvrtDosUnixTm (__le16 le_date,__le16 le_time, +int offset); extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, int oflags,
fs/cifs/cifssmb.c +2 -2
@@ -524,8 +524,8 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)int val, seconds, remain, result;struct timespec ts, utc; utc =CURRENT_TIME ; - ts =cnvrtDosUnixTm (le16_to_cpu (rsp->SrvTime.Date), -le16_to_cpu (rsp->SrvTime.Time)); + ts =cnvrtDosUnixTm (rsp->SrvTime.Date, + rsp->SrvTime.Time,0 );cFYI (1 , ("SrvTime %d sec since 1970 (utc: %d) diff: %d" , (int )ts.tv_sec, (int )utc.tv_sec, (int )(utc.tv_sec - ts.tv_sec)));
fs/cifs/netmisc.c +4 -8
@@ -883,16 +883,12 @@ cifs_UnixTimeToNT(struct timespec t)static int total_days_of_prev_months[] = {0 ,31 ,59 ,90 ,120 ,151 ,181 ,212 ,243 ,273 ,304 ,334 }; - -__le64 cnvrtDosCifsTm (__u16 date,__u16 time) -{ -return cpu_to_le64 (cifs_UnixTimeToNT (cnvrtDosUnixTm (date, time))); -} - -struct timespec cnvrtDosUnixTm (__u16 date,__u16 time) +struct timespec cnvrtDosUnixTm (__le16 le_date,__le16 le_time,int offset) {struct timespec ts;int sec, min, days, month, year; +u16 date =le16_to_cpu (le_date); +u16 time =le16_to_cpu (le_time);SMB_TIME *st = (SMB_TIME *)&time;SMB_DATE *sd = (SMB_DATE *)&date;
@@ -933,7 +929,7 @@ struct timespec cnvrtDosUnixTm(__u16 date, __u16 time) days -= ((year &0x03 ) ==0 ) && (month <2 ?1 :0 ); sec +=24 *60 *60 * days; - ts.tv_sec = sec; + ts.tv_sec = sec + offset;/* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */
fs/cifs/readdir.c +10 -22
@@ -115,17 +115,6 @@ construct_dentry(struct qstr *qstring, struct file *file,return rc; } -static void AdjustForTZ (struct cifsTconInfo *tcon,struct inode *inode) -{ -if ((tcon) && (tcon->ses) && (tcon->ses->server)) { - inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; - inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; - inode->i_atime.tv_sec += tcon->ses->server->timeAdj; - } -return ; -} - -static void fill_in_inode (struct inode *tmp_inode,int new_buf_type,char *buf,unsigned int *pobject_type,int isNewInode) {
@@ -156,20 +145,19 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, tmp_inode->i_ctime =cifs_NTtimeToUnix (pfindData->ChangeTime); }else {/* legacy, OS2 and DOS style */ -/* struct timespec ts;*/ +int offset = cifs_sb->tcon->ses->server->timeAdj;FIND_FILE_STANDARD_INFO *pfindData = (FIND_FILE_STANDARD_INFO *)buf; - tmp_inode->i_mtime =cnvrtDosUnixTm ( -le16_to_cpu (pfindData->LastWriteDate), -le16_to_cpu (pfindData->LastWriteTime)); - tmp_inode->i_atime =cnvrtDosUnixTm ( -le16_to_cpu (pfindData->LastAccessDate), -le16_to_cpu (pfindData->LastAccessTime)); - tmp_inode->i_ctime =cnvrtDosUnixTm ( -le16_to_cpu (pfindData->LastWriteDate), -le16_to_cpu (pfindData->LastWriteTime)); -AdjustForTZ (cifs_sb->tcon, tmp_inode); + tmp_inode->i_mtime =cnvrtDosUnixTm (pfindData->LastWriteDate, + pfindData->LastWriteTime, + offset); + tmp_inode->i_atime =cnvrtDosUnixTm (pfindData->LastAccessDate, + pfindData->LastAccessTime, + offset); + tmp_inode->i_ctime =cnvrtDosUnixTm (pfindData->LastWriteDate, + pfindData->LastWriteTime, + offset); attr =le16_to_cpu (pfindData->Attributes); allocation_size =le32_to_cpu (pfindData->AllocationSize); end_of_file =le32_to_cpu (pfindData->DataSize);
Signature · 1 line
1.6.2.2
PATCH 3/10 cifs: reorganize get_cifs_acl
In reply to Jeff LaytonFrom: Christoph Hellwig <[email protected]>
Thus spake Christoph:
"But this whole set_cifs_acl function is a real mess anyway and needs some splitting up."
With this change too, it's possible to call acl_to_uid_mode() with a NULL inode pointer. That (or something close to it) will eventually be necessary when cifs_get_inode_info is reorganized.
--- fs/cifs/cifsacl.c | 100 ++++++++++++++++++++++++++------------------------ fs/cifs/cifsproto.h | 4 +- fs/cifs/inode.c | 2 +- 3 files changed, 55 insertions(+), 51 deletions(-)
fs/cifs/cifsacl.c +52 -48
@@ -552,67 +552,66 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,return rc; } - -/* Retrieve an ACL from the server */ -static struct cifs_ntsd *get_cifs_acl (u32 *pacllen,struct inode *inode, -const char *path,const __u16 *pfid) +static struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb, +__u16 fid,u32 *pacllen) { -struct cifsFileInfo *open_file =NULL ; -bool unlock_file = false; -int xid; -int rc = -EIO ; -__u16 fid; -struct super_block *sb; -struct cifs_sb_info *cifs_sb;struct cifs_ntsd *pntsd =NULL ; +int xid, rc; -cFYI (1 , ("get mode from ACL for %s" , path)); + xid =GetXid (); + rc =CIFSSMBGetCIFSACL (xid, cifs_sb->tcon, fid, &pntsd, pacllen); +FreeXid (xid); -if (inode ==NULL ) -return NULL ; - xid =GetXid (); -if (pfid ==NULL ) - open_file =find_readable_file (CIFS_I (inode)); -else - fid = *pfid; +cFYI (1 , ("GetCIFSACL rc = %d ACL len %d" , rc, *pacllen)); +return pntsd; +} - sb = inode->i_sb; -if (sb ==NULL ) { -FreeXid (xid); -return NULL ; - } - cifs_sb =CIFS_SB (sb); +static struct cifs_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb, +const char *path,u32 *pacllen) +{ +struct cifs_ntsd *pntsd =NULL ; +int oplock =0 ; +int xid, rc; +__u16 fid; -if (open_file) { - unlock_file = true; - fid = open_file->netfid; - }else if (pfid ==NULL ) { -int oplock =0 ; -/* open file */ - rc =CIFSSMBOpen (xid, cifs_sb->tcon, path,FILE_OPEN , -READ_CONTROL ,0 , &fid, &oplock,NULL , - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); -if (rc !=0 ) { -cERROR (1 , ("Unable to open file to get ACL" )); -FreeXid (xid); -return NULL ; - } + xid =GetXid (); + + rc =CIFSSMBOpen (xid, cifs_sb->tcon, path,FILE_OPEN ,READ_CONTROL ,0 , + &fid, &oplock,NULL , cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ); +if (rc) { +cERROR (1 , ("Unable to open file to get ACL" )); + goto out; } rc =CIFSSMBGetCIFSACL (xid, cifs_sb->tcon, fid, &pntsd, pacllen);cFYI (1 , ("GetCIFSACL rc = %d ACL len %d" , rc, *pacllen)); -if (unlock_file == true)/* find_readable_file increments ref count */ -atomic_dec (&open_file->wrtPending); -else if (pfid ==NULL )/* if opened above we have to close the handle */ -CIFSSMBClose (xid, cifs_sb->tcon, fid); -/* else handle was passed in by caller */ +CIFSSMBClose (xid, cifs_sb->tcon, fid); + out:FreeXid (xid);return pntsd; } +/* Retrieve an ACL from the server */ +static struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb, +struct inode *inode,const char *path, +u32 *pacllen) +{ +struct cifs_ntsd *pntsd =NULL ; +struct cifsFileInfo *open_file =NULL ; + +if (inode) + open_file =find_readable_file (CIFS_I (inode)); +if (!open_file) +return get_cifs_acl_by_path (cifs_sb, path, pacllen); + + pntsd =get_cifs_acl_by_fid (cifs_sb, open_file->netfid, pacllen); +atomic_dec (&open_file->wrtPending); +return pntsd; +} +/* Set an ACL on the server */ static int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen,struct inode *inode,const char *path)
@@ -668,14 +667,19 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, }/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ -void acl_to_uid_mode (struct inode *inode,const char *path,const __u16 *pfid) +void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, +const char *path,const __u16 *pfid) {struct cifs_ntsd *pntsd =NULL ;u32 acllen =0 ;int rc =0 ;cFYI (DBG2 , ("converting ACL to mode for %s" , path)); - pntsd =get_cifs_acl (&acllen, inode, path, pfid); + +if (pfid) + pntsd =get_cifs_acl_by_fid (cifs_sb, *pfid, &acllen); +else + pntsd =get_cifs_acl (cifs_sb, inode, path, &acllen);/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ if (pntsd)
@@ -698,7 +702,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)cFYI (DBG2 , ("set ACL from mode for %s" , path));/* Get the security descriptor */ - pntsd =get_cifs_acl (&secdesclen, inode, path,NULL ); + pntsd =get_cifs_acl (CIFS_SB (inode->i_sb), inode, path, &secdesclen);/* Add three ACEs for owner, group, everyone getting rid of other ACEs as chmod disables ACEs and set the security descriptor */
fs/cifs/cifsproto.h +2 -2
@@ -108,8 +108,8 @@ extern int cifs_get_inode_info(struct inode **pinode,extern int cifs_get_inode_info_unix (struct inode **pinode,const unsigned char *search_path,struct super_block *sb,int xid); -extern void acl_to_uid_mode (struct inode *inode,const char *path, -const __u16 *pfid); +extern void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, +const char *path,const __u16 *pfid);extern int mode_to_acl (struct inode *inode,const char *path,__u64 ); extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
fs/cifs/inode.c +1 -1
@@ -626,7 +626,7 @@ int cifs_get_inode_info(struct inode **pinode,/* fill in 0777 bits from ACL */ if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) {cFYI (1 , ("Getting mode bits from ACL" )); -acl_to_uid_mode (inode, full_path, pfid); +acl_to_uid_mode (cifs_sb, inode, full_path, pfid); }#endif if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL ) {
Signature · 1 line
1.6.2.2
Re: [PATCH 03/10] cifs: reorganize get_cifs_acl
Quoted 197 lines · Jeff Layton
From: Christoph Hellwig <[email protected]>
Thus spake Christoph:
"But this whole
set_cifs_aclfunction is a real mess anyway and needs some splitting up."With this change too, it's possible to call
acl_to_uid_mode()with a NULL inode pointer. That (or something close to it) will eventually be necessary whencifs_get_inode_infois reorganized.Signed-off-by Christoph Hellwig <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/cifsacl.c | 100 ++++++++++++++++++++++++++------------------------fs/cifs/cifsproto.h| 4 +-
fs/cifs/inode.c | 2 +-3 files changed, 55 insertions(+), 51 deletions(-)fs/cifs/cifsacl.c +52
-48@@ -552,67 +552,66 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, return rc; } - -/* Retrieve an ACL from the server */ -static struct cifs_ntsd *get_cifs_acl (u32 *pacllen,struct inode *inode, - const char *path, const __u16 *pfid) +static struct cifs_ntsd *get_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb, + __u16 fid, u32 *pacllen) { - struct cifsFileInfo *open_file = NULL; - bool unlock_file = false; - int xid; - int rc = -EIO; - __u16 fid; - struct super_block *sb; - struct cifs_sb_info *cifs_sb; struct cifs_ntsd *pntsd = NULL; + int xid, rc; - cFYI(1, ("get mode from ACL for %s", path)); + xid = GetXid(); + rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen); + FreeXid(xid); - if (inode == NULL) - return NULL; - xid = GetXid(); - if (pfid == NULL) - open_file = find_readable_file(CIFS_I(inode)); - else - fid = *pfid; + cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen)); + return pntsd; +} - sb = inode->i_sb; - if (sb == NULL) { - FreeXid(xid); - return NULL; - } - cifs_sb = CIFS_SB(sb); +static struct cifs_ntsd *get_cifs_acl_by_path (struct cifs_sb_info *cifs_sb, + const char *path, u32 *pacllen) +{ + struct cifs_ntsd *pntsd = NULL; + int oplock = 0; + int xid, rc; + __u16 fid; - if (open_file) { - unlock_file = true; - fid = open_file->netfid; - } else if (pfid == NULL) { - int oplock = 0; - /* open file */ - rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, - READ_CONTROL, 0, &fid, &oplock, NULL, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & - CIFS_MOUNT_MAP_SPECIAL_CHR); - if (rc != 0) { - cERROR(1, ("Unable to open file to get ACL")); - FreeXid(xid); - return NULL; - } + xid = GetXid(); + + rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, READ_CONTROL, 0, + &fid, &oplock, NULL, cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); + if (rc) { + cERROR(1, ("Unable to open file to get ACL")); + goto out; } rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen); cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen)); - if (unlock_file == true) /* find_readable_file increments ref count */ - atomic_dec(&open_file->wrtPending); - else if (pfid == NULL) /* if opened above we have to close the handle */ - CIFSSMBClose(xid, cifs_sb->tcon, fid); - /* else handle was passed in by caller */ + CIFSSMBClose(xid, cifs_sb->tcon, fid); + out: FreeXid(xid); return pntsd; } +/* Retrieve an ACL from the server */ +static struct cifs_ntsd *get_cifs_acl (struct cifs_sb_info *cifs_sb, + struct inode *inode, const char *path, + u32 *pacllen) +{ + struct cifs_ntsd *pntsd = NULL; + struct cifsFileInfo *open_file = NULL; + + if (inode) + open_file = find_readable_file(CIFS_I(inode)); + if (!open_file) + return get_cifs_acl_by_path(cifs_sb, path, pacllen); + + pntsd = get_cifs_acl_by_fid(cifs_sb, open_file->netfid, pacllen); + atomic_dec(&open_file->wrtPending); + return pntsd; +} + /* Set an ACL on the server */ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, struct inode *inode, const char *path)@@ -668,14 +667,19 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, } /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ -void acl_to_uid_mode (struct inode *inode,const char *path,const __u16 *pfid) +void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, + const char *path, const __u16 *pfid) { struct cifs_ntsd *pntsd = NULL; u32 acllen = 0; int rc = 0; cFYI(DBG2, ("converting ACL to mode for %s", path)); - pntsd = get_cifs_acl(&acllen, inode, path, pfid); + + if (pfid) + pntsd = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen); + else + pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ if (pntsd)@@ -698,7 +702,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) cFYI(DBG2, ("set ACL from mode for %s", path)); /* Get the security descriptor */ - pntsd = get_cifs_acl(&secdesclen, inode, path, NULL); + pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen); /* Add three ACEs for owner, group, everyone getting rid ofother ACEs as chmod disables ACEs and set the security descriptor */
fs/cifs/cifsproto.h +2
-2@@ -108,8 +108,8 @@ extern int cifs_get_inode_info(struct inode **pinode, extern int cifs_get_inode_info_unix(struct inode **pinode, const unsigned char *search_path, struct super_block *sb, int xid); -extern void acl_to_uid_mode (struct inode *inode,const char *path, - const __u16 *pfid); +extern void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, + const char *path, const __u16 *pfid); extern int mode_to_acl(struct inode *inode, const char *path, __u64); extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,fs/cifs/inode.c +1
-2@@ -626,7 +626,7 @@ int cifs_get_inode_info(struct inode **pinode, /* fill in 0777 bits from ACL */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { cFYI(1, ("Getting mode bits from ACL")); - acl_to_uid_mode(inode, full_path, pfid); + acl_to_uid_mode(cifs_sb, inode, full_path, pfid); } #endif if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { --1.6.2.2
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Looks good.
PATCH 4/10 cifs: clean up set_cifs_acl interfaces
In reply to Jeff LaytonFrom: Christoph Hellwig <[email protected]>
--- fs/cifs/cifsacl.c | 78 ++++++++++++++++++++++++++++------------------------- 1 files changed, 41 insertions(+), 37 deletions(-)
fs/cifs/cifsacl.c +41 -37
@@ -612,57 +612,61 @@ static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,return pntsd; } -/* Set an ACL on the server */ -static int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, -struct inode *inode,const char *path) +static int set_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb,__u16 fid, +struct cifs_ntsd *pnntsd,u32 acllen) { -struct cifsFileInfo *open_file; -bool unlock_file = false; -int xid; -int rc = -EIO ; -__u16 fid; -struct super_block *sb; -struct cifs_sb_info *cifs_sb; +int xid, rc; -cFYI (DBG2 , ("set ACL for %s from mode 0x%x" , path, inode->i_mode)); + xid =GetXid (); + rc =CIFSSMBSetCIFSACL (xid, cifs_sb->tcon, fid, pnntsd, acllen); +FreeXid (xid); -if (!inode) -return rc; +cFYI (DBG2 , ("SetCIFSACL rc = %d" , rc)); +return rc; +} - sb = inode->i_sb; -if (sb ==NULL ) -return rc; +static int set_cifs_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path, +struct cifs_ntsd *pnntsd,u32 acllen) +{ +int oplock =0 ; +int xid, rc; +__u16 fid; - cifs_sb =CIFS_SB (sb); xid =GetXid (); - open_file =find_readable_file (CIFS_I (inode)); -if (open_file) { - unlock_file = true; - fid = open_file->netfid; - }else { -int oplock =0 ; -/* open file */ - rc =CIFSSMBOpen (xid, cifs_sb->tcon, path,FILE_OPEN , -WRITE_DAC ,0 , &fid, &oplock,NULL , - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); -if (rc !=0 ) { -cERROR (1 , ("Unable to open file to set ACL" )); -FreeXid (xid); -return rc; - } + rc =CIFSSMBOpen (xid, cifs_sb->tcon, path,FILE_OPEN ,WRITE_DAC ,0 , + &fid, &oplock,NULL , cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ); +if (rc) { +cERROR (1 , ("Unable to open file to set ACL" )); + goto out; } rc =CIFSSMBSetCIFSACL (xid, cifs_sb->tcon, fid, pnntsd, acllen);cFYI (DBG2 , ("SetCIFSACL rc = %d" , rc)); -if (unlock_file) -atomic_dec (&open_file->wrtPending); -else -CIFSSMBClose (xid, cifs_sb->tcon, fid); +CIFSSMBClose (xid, cifs_sb->tcon, fid); + out:FreeXid (xid); +return rc; +} +/* Set an ACL on the server */ +static int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, +struct inode *inode,const char *path) +{ +struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); +struct cifsFileInfo *open_file; +int rc; + +cFYI (DBG2 , ("set ACL for %s from mode 0x%x" , path, inode->i_mode)); + + open_file =find_readable_file (CIFS_I (inode)); +if (!open_file) +return set_cifs_acl_by_path (cifs_sb, path, pnntsd, acllen); + + rc =set_cifs_acl_by_fid (cifs_sb, open_file->netfid, pnntsd, acllen); +atomic_dec (&open_file->wrtPending);return rc; }
Signature · 1 line
1.6.2.2
Re: [linux-cifs-client] [PATCH 04/10] cifs: clean up set_cifs_acl interfaces
Quoted 114 lines · Jeff Layton
From: Christoph Hellwig <[email protected]>
Signed-off-by Christoph Hellwig <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/cifsacl.c | 78 ++++++++++++++++++++++++++++-------------------------1 files changed, 41 insertions(+), 37 deletions(-)fs/cifs/cifsacl.c +41
-38@@ -612,57 +612,61 @@ static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, return pntsd; } -/* Set an ACL on the server */ -static int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, - struct inode *inode, const char *path) +static int set_cifs_acl_by_fid (struct cifs_sb_info *cifs_sb,__u16 fid, + struct cifs_ntsd *pnntsd, u32 acllen) { - struct cifsFileInfo *open_file; - bool unlock_file = false; - int xid; - int rc = -EIO; - __u16 fid; - struct super_block *sb; - struct cifs_sb_info *cifs_sb; + int xid, rc; - cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); + xid = GetXid(); + rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); + FreeXid(xid); - if (!inode) - return rc; + cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); + return rc; +} - sb = inode->i_sb; - if (sb == NULL) - return rc; +static int set_cifs_acl_by_path (struct cifs_sb_info *cifs_sb,const char *path, + struct cifs_ntsd *pnntsd, u32 acllen) +{ + int oplock = 0; + int xid, rc; + __u16 fid; - cifs_sb = CIFS_SB(sb); xid = GetXid(); - open_file = find_readable_file(CIFS_I(inode)); - if (open_file) { - unlock_file = true; - fid = open_file->netfid; - } else { - int oplock = 0; - /* open file */ - rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, - WRITE_DAC, 0, &fid, &oplock, NULL, - cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & - CIFS_MOUNT_MAP_SPECIAL_CHR); - if (rc != 0) { - cERROR(1, ("Unable to open file to set ACL")); - FreeXid(xid); - return rc; - } + rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, WRITE_DAC, 0, + &fid, &oplock, NULL, cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); + if (rc) { + cERROR(1, ("Unable to open file to set ACL")); + goto out; } rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); - if (unlock_file) - atomic_dec(&open_file->wrtPending); - else - CIFSSMBClose(xid, cifs_sb->tcon, fid); + CIFSSMBClose(xid, cifs_sb->tcon, fid); + out: FreeXid(xid); + return rc; +} +/* Set an ACL on the server */ +static int set_cifs_acl (struct cifs_ntsd *pnntsd,__u32 acllen, + struct inode *inode, const char *path) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + struct cifsFileInfo *open_file; + int rc; + + cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); + + open_file = find_readable_file(CIFS_I(inode)); + if (!open_file) + return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); + + rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen); + atomic_dec(&open_file->wrtPending); return rc; } --1.6.2.2
Quoted 5 lines
_______________________________________________
linux-cifs-client mailing list
[email protected]
https://lists.samba.org/mailman/listinfo/linux-cifs-client
Looks good
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/10 cifs: rename cifs_iget to cifs_root_iget
In reply to Jeff LaytonThe current cifs_iget isn't suitable for anything but the root inode. Rename it with a more appropriate name.
--- fs/cifs/cifsfs.c | 2 +- fs/cifs/cifsfs.h | 2 +- fs/cifs/inode.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/cifsfs.c +1 -1
@@ -146,7 +146,7 @@ cifs_read_super(struct super_block *sb, void *data,#endif sb->s_blocksize =CIFS_MAX_MSGSIZE ; sb->s_blocksize_bits =14 ;/* default 2**14 = CIFS_MAX_MSGSIZE */ - inode =cifs_iget (sb,ROOT_I ); + inode =cifs_root_iget (sb,ROOT_I );if (IS_ERR (inode)) { rc =PTR_ERR (inode);
fs/cifs/cifsfs.h +1 -1
@@ -36,7 +36,7 @@ extern void cifs_read_inode(struct inode *);/* Functions related to inodes */ extern const struct inode_operations cifs_dir_inode_ops; -extern struct inode *cifs_iget (struct super_block *,unsigned long ); +extern struct inode *cifs_root_iget (struct super_block *,unsigned long );extern int cifs_create (struct inode *,struct dentry *,int ,struct nameidata *); extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
fs/cifs/inode.c +1 -1
@@ -696,7 +696,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb) }/* gets root inode */ -struct inode *cifs_iget (struct super_block *sb,unsigned long ino) +struct inode *cifs_root_iget (struct super_block *sb,unsigned long ino) {int xid;struct cifs_sb_info *cifs_sb;
Signature · 1 line
1.6.2.2
PATCH 6/10 cifs: add new cifs_iget function and convert unix codepath to use it
In reply to Jeff LaytonIn order to unify some codepaths, introduce a common cifs_fattr struct for storing inode attributes. The different codepaths (unix, legacy, normal, etc...) can fill out this struct with inode info. It can then be passed as an arg to a common set of routines to get and update inodes.
Add a new cifs_iget function that uses iget5_locked to identify inodes. This will compare inodes based on the uniqueid value in a cifs_fattr struct.
Rather than filling out an already-created inode, have cifs_get_inode_info_unix instead fill out cifs_fattr and hand that off to cifs_iget. cifs_iget can then properly look for hardlinked inodes.
On the readdir side, add a new cifs_readdir_lookup function that spawns populated dentries. Redefine FILE_UNIX_INFO so that it's basically a FILE_UNIX_BASIC_INFO that has a few fields wrapped around it. This allows us to more easily use the same function for filling out the fattr as the non-readdir codepath.
With this, we should then have proper hardlink detection and can eventually get rid of some nasty CIFS-specific hacks for handing them.
--- fs/cifs/cifsfs.h | 13 ++ fs/cifs/cifsglob.h | 25 ++++ fs/cifs/cifspdu.h | 14 +-- fs/cifs/cifsproto.h | 9 +- fs/cifs/dir.c | 22 ++-- fs/cifs/inode.c | 380 ++++++++++++++++++++++++++------------------------- fs/cifs/readdir.c | 253 ++++++++++++---------------------- 7 files changed, 339 insertions(+), 377 deletions(-)
fs/cifs/cifsfs.h +13 -0
@@ -24,6 +24,19 @@#define ROOT_I 2 +/* +* ino_t is 32-bits on 32-bit arch. We have to squash the 64-bit value down +* so that it will fit. +*/ +static inline ino_t +cifs_uniqueid_to_ino_t (u64 fileid) +{ +ino_t ino = (ino_t ) fileid; +if (sizeof (ino_t) <sizeof (u64)) + ino ^= fileid >> (sizeof (u64)-sizeof (ino_t)) *8 ; +return ino; +} +extern struct file_system_type cifs_fs_type;extern const struct address_space_operations cifs_addr_ops;extern const struct address_space_operations cifs_addr_ops_smallbuf;
fs/cifs/cifsglob.h +25 -0
@@ -371,6 +371,7 @@ struct cifsInodeInfo { bool oplockPending:1; bool delete_pending:1; /* DELETE_ON_CLOSE is set */u64 server_eof;/* current file size on server */ +u64 uniqueid;/* server inode number */ struct inode vfs_inode; };
@@ -472,6 +473,30 @@ struct dfs_info3_param {char *node_name; }; +/* +* common struct for holding inode info when searching for or updating an +* inode with new info +*/ + +#define CIFS_FATTR_DFS_REFERRAL 0x1 + +struct cifs_fattr { +u32 cf_flags; +u32 cf_cifsattrs; +u64 cf_uniqueid; +u64 cf_eof; +u64 cf_bytes; +uid_t cf_uid; +gid_t cf_gid; +umode_t cf_mode; +dev_t cf_rdev; +unsigned int cf_nlink; +unsigned int cf_dtype; +struct timespec cf_atime; +struct timespec cf_mtime; +struct timespec cf_ctime; +}; +static inline void free_dfs_info_param (struct dfs_info3_param *param) {if (param) {
fs/cifs/cifspdu.h +1 -13
@@ -2328,19 +2328,7 @@ struct file_attrib_tag {typedef struct {__le32 NextEntryOffset;__u32 ResumeKey;/* as with FileIndex - no need to convert */ -__le64 EndOfFile; -__le64 NumOfBytes; -__le64 LastStatusChange;/*SNIA specs DCE time for the 3 time fields */ -__le64 LastAccessTime; -__le64 LastModificationTime; -__le64 Uid; -__le64 Gid; -__le32 Type; -__le64 DevMajor; -__le64 DevMinor; -__le64 UniqueId; -__le64 Permissions; -__le64 Nlinks; +FILE_UNIX_BASIC_INFO basic;char FileName[1 ]; } __attribute__((packed))FILE_UNIX_INFO ;/* level 0x202 */
fs/cifs/cifsproto.h +7 -2
@@ -98,9 +98,14 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,extern int cifs_posix_open (char *full_path,struct inode **pinode,struct super_block *sb,int mode,int oflags,int *poplock,__u16 *pnetfid,int xid); -extern void posix_fill_in_inode (struct inode *tmp_inode, -FILE_UNIX_BASIC_INFO *pData,int isNewInode); +extern void cifs_unix_basic_to_fattr (struct cifs_fattr *fattr, +FILE_UNIX_BASIC_INFO *info, +struct cifs_sb_info *cifs_sb); +extern void cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr);extern struct inode *cifs_new_inode (struct super_block *sb,__u64 *inum); +extern struct inode *cifs_iget (struct super_block *sb, +struct cifs_fattr *fattr); + extern int cifs_get_inode_info(struct inode **pinode, const unsigned char *search_path, FILE_ALL_INFO *pfile_info,
fs/cifs/dir.c +11 -11
@@ -188,6 +188,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,FILE_UNIX_BASIC_INFO *presp_data;__u32 posix_flags =0 ;struct cifs_sb_info *cifs_sb =CIFS_SB (sb); +struct cifs_fattr fattr;cFYI (1 , ("posix open %s" , full_path));
@@ -236,22 +237,21 @@ int cifs_posix_open(char *full_path, struct inode **pinode,if (presp_data->Type ==cpu_to_le32 (-1 )) goto posix_open_ret;/* open ok, caller does qpathinfo */ -/* get new inode and set it up */ if (!pinode) goto posix_open_ret;/* caller does not need info */ +cifs_unix_basic_to_fattr (&fattr, presp_data, cifs_sb); + +/* get new inode and set it up */ if (*pinode ==NULL ) { -__u64 unique_id =le64_to_cpu (presp_data->UniqueId); - *pinode =cifs_new_inode (sb, &unique_id); + *pinode =cifs_iget (sb, &fattr); +if (!*pinode) { + rc = -ENOMEM ; + goto posix_open_ret; + } + }else { +cifs_fattr_to_inode (*pinode, &fattr); } -/* else an inode was passed in. Update its info, don't create one */ - -/* We do not need to close the file if new_inode fails since -the caller will retry qpathinfo as long as inode is null */ -if (*pinode ==NULL ) - goto posix_open_ret; - -posix_fill_in_inode (*pinode, presp_data,1 );cifs_fill_fileinfo (*pinode, *pnetfid, cifs_sb->tcon, write_only);
fs/cifs/inode.c +192 -188
508 lines not on this page · raw message
fs/cifs/readdir.c +90 -163
304 lines not on this page · raw message
Signature · 1 line
1.6.2.2
PATCH 7/10 cifs: convert cifs_get_inode_info and non-posix readdir to use cifs_iget
In reply to Jeff LaytonRather than allocating an inode and filling it out, have cifs_get_inode_info fill out a cifs_fattr and call cifs_iget. This means a pretty hefty reorganization of cifs_get_inode_info.
For the readdir codepath, add a couple of new functions for filling out cifs_fattr's from different FindFile response infolevels.
Finally, remove cifs_new_inode since there are no more callers.
--- fs/cifs/cifsacl.c | 26 ++-- fs/cifs/cifsglob.h | 2 + fs/cifs/cifsproto.h | 6 +- fs/cifs/inode.c | 397 +++++++++++++++++++------------------------------- fs/cifs/readdir.c | 350 +++++++++++---------------------------------- 5 files changed, 252 insertions(+), 529 deletions(-)
fs/cifs/cifsacl.c +13 -13
@@ -327,7 +327,7 @@ static void dump_ace(struct cifs_ace *pace, char *end_of_acl)static void parse_dacl (struct cifs_acl *pdacl,char *end_of_acl,struct cifs_sid *pownersid,struct cifs_sid *pgrpsid, -struct inode *inode) +struct cifs_fattr *fattr) {int i;int num_aces =0 ;
@@ -340,7 +340,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,if (!pdacl) {/* no DACL in the security descriptor, set all the permissions for user/group/other */ - inode->i_mode |=S_IRWXUGO ; + fattr->cf_mode |=S_IRWXUGO ;return ; }
@@ -357,7 +357,7 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,/* reset rwx permissions for user/group/other. Also, if num_aces is 0 i.e. DACL has no ACEs, user/group/other have no permissions */ - inode->i_mode &= ~(S_IRWXUGO ); + fattr->cf_mode &= ~(S_IRWXUGO ); acl_base = (char *)pdacl; acl_size =sizeof (struct cifs_acl );
@@ -379,17 +379,17 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,if (compare_sids (&(ppace[i]->sid), pownersid))access_flags_to_mode (ppace[i]->access_req, ppace[i]->type, - &(inode->i_mode), + &fattr->cf_mode, &user_mask);if (compare_sids (&(ppace[i]->sid), pgrpsid))access_flags_to_mode (ppace[i]->access_req, ppace[i]->type, - &(inode->i_mode), + &fattr->cf_mode, &group_mask);if (compare_sids (&(ppace[i]->sid), &sid_everyone))access_flags_to_mode (ppace[i]->access_req, ppace[i]->type, - &(inode->i_mode), + &fattr->cf_mode, &other_mask);/* memcpy((void *)(&(cifscred->aces[i])),
@@ -464,7 +464,7 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl)/* Convert CIFS ACL to POSIX form */ static int parse_sec_desc (struct cifs_ntsd *pntsd,int acl_len, -struct inode *inode) +struct cifs_fattr *fattr) {int rc;struct cifs_sid *owner_sid_ptr, *group_sid_ptr;
@@ -472,7 +472,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,char *end_of_acl = ((char *)pntsd) + acl_len;__u32 dacloffset; -if ((inode ==NULL ) || (pntsd ==NULL )) +if (pntsd ==NULL )return -EIO ; owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
@@ -497,7 +497,7 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,if (dacloffset)parse_dacl (dacl_ptr, end_of_acl, owner_sid_ptr, - group_sid_ptr, inode); + group_sid_ptr, fattr);else cFYI (1 , ("no ACL" ));/* BB grant all or default perms? */
@@ -508,7 +508,6 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len,memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, sizeof(struct cifs_sid)); */ -return 0 ; }
@@ -671,8 +670,9 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, }/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ -void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, -const char *path,const __u16 *pfid) +void +cifs_acl_to_fattr (struct cifs_sb_info *cifs_sb,struct cifs_fattr *fattr, +struct inode *inode,const char *path,const __u16 *pfid) {struct cifs_ntsd *pntsd =NULL ;u32 acllen =0 ;
@@ -687,7 +687,7 @@ void acl_to_uid_mode(struct cifs_sb_info *cifs_sb, struct inode *inode,/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ if (pntsd) - rc =parse_sec_desc (pntsd, acllen, inode); + rc =parse_sec_desc (pntsd, acllen, fattr);if (rc)cFYI (1 , ("parse sec desc failed rc = %d" , rc));
fs/cifs/cifsglob.h +2 -0
@@ -479,6 +479,8 @@ struct dfs_info3_param {*/ #define CIFS_FATTR_DFS_REFERRAL 0x1 +#define CIFS_FATTR_DELETE_PENDING 0x2 +#define CIFS_FATTR_NEED_REVAL 0x4struct cifs_fattr {u32 cf_flags;
fs/cifs/cifsproto.h +3 -3
@@ -102,7 +102,6 @@ extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,FILE_UNIX_BASIC_INFO *info, struct cifs_sb_info *cifs_sb);extern void cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr); -extern struct inode *cifs_new_inode (struct super_block *sb,__u64 *inum);extern struct inode *cifs_iget (struct super_block *sb,struct cifs_fattr *fattr);
@@ -113,8 +112,9 @@ extern int cifs_get_inode_info(struct inode **pinode,extern int cifs_get_inode_info_unix (struct inode **pinode,const unsigned char *search_path,struct super_block *sb,int xid); -extern void acl_to_uid_mode (struct cifs_sb_info *cifs_sb,struct inode *inode, -const char *path,const __u16 *pfid); +extern void cifs_acl_to_fattr (struct cifs_sb_info *cifs_sb, +struct cifs_fattr *fattr,struct inode *inode, +const char *path,const __u16 *pfid);extern int mode_to_acl (struct inode *inode,const char *path,__u64 ); extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
fs/cifs/inode.c +151 -246
545 lines not on this page · raw message
fs/cifs/readdir.c +83 -267
404 lines not on this page · raw message
Signature · 1 line
1.6.2.2
PATCH 8/10 cifs: make serverino the default when mounting
In reply to Jeff Layton--- fs/cifs/connect.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/cifs/connect.c +2 -0
@@ -835,6 +835,8 @@ cifs_parse_mount_options(char *options, const char *devname, vol->rw = true;/* default is always to request posix paths. */ vol->posix_paths =1 ; +/* default to using server inode numbers where available */ + vol->server_ino =1 ;if (!options)return 1 ;
Signature · 1 line
1.6.2.2
PATCH 9/10 cifs: remove cifsInodeInfo->inUse counter
In reply to Jeff LaytonIt was purported to be a refcounter of some sort, but was never used that way. It never served any purpose that wasn't served equally well by the I_NEW flag.
--- fs/cifs/cifsfs.c | 1 - fs/cifs/cifsglob.h | 1 - 2 files changed, 0 insertions(+), 2 deletions(-)
fs/cifs/cifsfs.c +0 -1
@@ -304,7 +304,6 @@ cifs_alloc_inode(struct super_block *sb)if (!cifs_inode)return NULL ; cifs_inode->cifsAttrs =0x20 ;/* default */ -atomic_set (&cifs_inode->inUse,0 ); cifs_inode->time =0 ; cifs_inode->write_behind_rc =0 ;/* Until the file is open and we have gotten oplock
fs/cifs/cifsglob.h +0 -1
@@ -364,7 +364,6 @@ struct cifsInodeInfo {struct list_head openFileList;int write_behind_rc;__u32 cifsAttrs;/* e.g. DOS archive bit, sparse, compressed, system */ -atomic_t inUse;/* num concurrent users (local openers cifs) of file*/ unsigned long time;/* jiffies of last update/check of inode */ bool clientCanCacheRead:1; /* read oplock */ bool clientCanCacheAll:1; /* read and writebehind oplock */
Signature · 1 line
1.6.2.2
PATCH 10/10 cifs: remove "hardlink detection" from cifs_rename
In reply to Jeff LaytonBecause cifs never handled hardlinks correctly, there was a rather nasty hack in cifs_rename to try and detect them. It only ever worked on POSIX mounts anyway. Now that cifs has proper hardlink detection, that can be removed.
--- fs/cifs/inode.c | 60 +------------------------------------------------------ 1 files changed, 1 insertions(+), 59 deletions(-)
fs/cifs/inode.c +1 -59
@@ -1287,29 +1287,11 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry, {char *fromName =NULL ;char *toName =NULL ; -struct cifs_sb_info *cifs_sb_source; -struct cifs_sb_info *cifs_sb_target; -struct cifsTconInfo *tcon; -FILE_UNIX_BASIC_INFO *info_buf_source =NULL ; -FILE_UNIX_BASIC_INFO *info_buf_target;int xid, rc, tmprc; - cifs_sb_target =CIFS_SB (target_dir->i_sb); - cifs_sb_source =CIFS_SB (source_dir->i_sb); - tcon = cifs_sb_source->tcon; - xid =GetXid ();/* -* BB: this might be allowed if same server, but different share. -* Consider adding support for this -*/ -if (tcon != cifs_sb_target->tcon) { - rc = -EXDEV ; - goto cifs_rename_exit; - } - -/* * we already have the rename sem so we do not need to * grab it again here to protect the path integrity */
@@ -1328,46 +1310,7 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry, rc =cifs_do_rename (xid, source_dentry, fromName, target_dentry, toName); -if (rc == -EEXIST && tcon->unix_ext) { -/* -* Are src and dst hardlinks of same inode? We can -* only tell with unix extensions enabled -*/ - info_buf_source = -kmalloc (2 *sizeof (FILE_UNIX_BASIC_INFO ), -GFP_KERNEL ); -if (info_buf_source ==NULL ) { - rc = -ENOMEM ; - goto cifs_rename_exit; - } - - info_buf_target = info_buf_source +1 ; - tmprc =CIFSSMBUnixQPathInfo (xid, tcon, fromName, - info_buf_source, - cifs_sb_source->local_nls, - cifs_sb_source->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); -if (tmprc !=0 ) - goto unlink_target; - - tmprc =CIFSSMBUnixQPathInfo (xid, tcon, - toName, info_buf_target, - cifs_sb_target->local_nls, -/* remap based on source sb */ - cifs_sb_source->mnt_cifs_flags & -CIFS_MOUNT_MAP_SPECIAL_CHR ); - -if (tmprc ==0 && (info_buf_source->UniqueId == - info_buf_target->UniqueId)) { -/* same file, POSIX says that this is a noop */ - rc =0 ; - goto cifs_rename_exit; - } - }/* else ... BB we could add the same check for Windows by -checking the UniqueId via FILE_INTERNAL_INFO */ - -unlink_target: -/* Try unlinking the target dentry if it's not negative */ +/* unlink the target, but only if it looks like the file exists */ if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST )) { tmprc =cifs_unlink (target_dir, target_dentry);if (tmprc)
@@ -1378,7 +1321,6 @@ unlink_target: } cifs_rename_exit: -kfree (info_buf_source);kfree (fromName);kfree (toName);FreeXid (xid);
Signature · 1 line
1.6.2.2