Author: asser Date: 2005-08-17 14:15:53 +0000 (Wed, 17 Aug 2005) New Revision: 35
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=linux-cifs-client&rev=35 Log: Started NT_CANCEL implementation and added locking of GlobalMid_Lock when doing list operations in is_valid_dnotify_rsp, CIFSSMBNotify and cifs_dnotify_thread. Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsfs.c branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsglob.h branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifspdu.h branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifssmb.c branches/SOC/linux-2.6bk-dnotify/fs/cifs/misc.c Changeset: Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsfs.c =================================================================== --- branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsfs.c 2005-08-13 16:15:58 UTC (rev 34) +++ branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsfs.c 2005-08-17 14:15:53 UTC (rev 35) @@ -858,7 +858,9 @@ set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1*HZ); + spin_lock(&GlobalMid_Lock); if(list_empty(&GlobalDnotifyRsp_Q)) { + spin_unlock(&GlobalMid_Lock); set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(39*HZ); } else { @@ -866,6 +868,7 @@ if(dnotify_req) { list_del(&dnotify_req->lhead); + spin_unlock(&GlobalMid_Lock); inode = dnotify_req->dentry->d_inode; cFYI(1,("Notifying file %s mask %lx", build_path_from_dentry(dnotify_req->dentry), inode->i_dnotify_mask)); Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsglob.h =================================================================== --- branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsglob.h 2005-08-13 16:15:58 UTC (rev 34) +++ branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifsglob.h 2005-08-17 14:15:53 UTC (rev 35) @@ -334,8 +334,10 @@ /* for pending dnotify requests */ struct dir_notify_req { struct list_head lhead; - __u16 Pid; + __le16 Pid; __u16 Mid; + __u16 Tid; + __u16 Uid; __u16 netfid; __u32 filter; /* CompletionFilter (for multishot) */ int multishot; Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifspdu.h =================================================================== --- branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifspdu.h 2005-08-13 16:15:58 UTC (rev 34) +++ branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifspdu.h 2005-08-17 14:15:53 UTC (rev 35) @@ -52,6 +52,7 @@ #define SMB_COM_NT_TRANSACT 0xA0 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 #define SMB_COM_NT_CREATE_ANDX 0xA2 +#define SMB_COM_NT_CANCEL 0xA4 /* no response, but might trigger response of cancelled request */ #define SMB_COM_NT_RENAME 0xA5 /* trivial response */ /* Transact2 subcommand codes */ Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifssmb.c =================================================================== --- branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifssmb.c 2005-08-13 16:15:58 UTC (rev 34) +++ branches/SOC/linux-2.6bk-dnotify/fs/cifs/cifssmb.c 2005-08-17 14:15:53 UTC (rev 35) @@ -3831,6 +3831,37 @@ return rc; } +int CIFSSMBCancel(const int xid, struct cifsTconInfo *tcon, + const int Sid, const int Uid, const int Pid, + const int Tid, const int Mid) +{ + int rc = 0; + struct smb_hdr *pSMB = NULL; + struct smb_hdr *pSMBr = NULL; + + int bytes_returned; + + cFYI(1,("In CIFSSMBCancel")); + rc = smb_init(SMB_COM_NT_CANCEL, 0, tcon, (void **) &pSMB, + (void **) &pSMBr); + + if(rc) + return rc; + + pSMB->Uid = Uid; + pSMB->Pid = Pid; + pSMB->Tid = Tid; + pSMB->Mid = Mid; + + rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, + (struct smb_hdr *) pSMBr, &bytes_returned, -1); + + if(rc) + cFYI(1,("Error in Cancel = %d", rc)); + cifs_buf_release(pSMB); + return rc; +} + int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, const int notify_subdirs, const __u16 netfid, __u32 filter, const struct nls_table *nls_codepage, @@ -3878,11 +3909,15 @@ sizeof(struct dir_notify_req), GFP_KERNEL); dnotify_req->Pid = pSMB->hdr.Pid; dnotify_req->Mid = pSMB->hdr.Mid; + dnotify_req->Tid = pSMB->hdr.Tid; + dnotify_req->Uid = pSMB->hdr.Uid; dnotify_req->netfid = netfid; dnotify_req->dentry = dentry; dnotify_req->filter = filter; dnotify_req->multishot = multishot; + spin_lock(&GlobalMid_Lock); list_add_tail(&dnotify_req->lhead, &GlobalDnotifyReqList); + spin_unlock(&GlobalMid_Lock); } cifs_buf_release(pSMB); return rc; Modified: branches/SOC/linux-2.6bk-dnotify/fs/cifs/misc.c =================================================================== --- branches/SOC/linux-2.6bk-dnotify/fs/cifs/misc.c 2005-08-13 16:15:58 UTC (rev 34) +++ branches/SOC/linux-2.6bk-dnotify/fs/cifs/misc.c 2005-08-17 14:15:53 UTC (rev 35) @@ -411,6 +411,7 @@ if((pSMBr->ByteCount > sizeof(struct file_notify_information)) || (pSMBr->hdr.Status.CifsError)) { /* Find the request on the req list */ + spin_lock(&GlobalMid_Lock); list_for_each_safe(tmp, tmp1, &GlobalDnotifyReqList) { dnotify_req = list_entry(tmp, struct dir_notify_req, lhead); @@ -421,6 +422,7 @@ list_add_tail(&dnotify_req->lhead, &GlobalDnotifyRsp_Q); } } + spin_unlock(&GlobalMid_Lock); wake_up_process(dnotifyThread); return TRUE; }
