Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 12000
b: refs/heads/master
c: dfb7533
h: refs/heads/master
v: v3
  • Loading branch information
Steve French authored and Steve French committed Jun 23, 2005
1 parent 0b015c0 commit 4c72a48
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 240 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 58aab753de605c14b9878a897e7349c3063afeff
refs/heads/master: dfb7533b5f157ac7135da23883e80d895227d965
3 changes: 3 additions & 0 deletions trunk/fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ struct cifsTconInfo {
atomic_t num_rmdirs;
atomic_t num_renames;
atomic_t num_t2renames;
atomic_t num_ffirst;
atomic_t num_fnext;
atomic_t num_fclose;
__u64 bytes_read;
__u64 bytes_written;
spinlock_t stat_lock;
Expand Down
6 changes: 1 addition & 5 deletions trunk/fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
struct smb_hdr * /* input */ ,
struct smb_hdr * /* out */ ,
int * /* bytes returned */ , const int long_op);
extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo *,
struct smb_hdr * /* input */ , int hdr_len,
const char * /* SMB data to send */ , int data_len,
int * /* bytes returned */ , const int long_op);
extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid);
extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length);
extern int is_valid_oplock_break(struct smb_hdr *smb);
Expand Down Expand Up @@ -226,7 +222,7 @@ extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count,
const __u64 offset, unsigned int *nbytes,
const char *buf,const int long_op);
const char __user *buf,const int long_op);
extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
const unsigned char *searchName, __u64 * inode_number,
const struct nls_table *nls_codepage,
Expand Down
70 changes: 33 additions & 37 deletions trunk/fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,69 +951,56 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
}

#ifdef CONFIG_CIFS_EXPERIMENTAL
int
CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count,
const __u64 offset, unsigned int *nbytes, const char *buf,
const __u64 offset, unsigned int *nbytes, const char __user *buf,
const int long_op)
{
int rc = -EACCES;
WRITE_REQ *pSMB = NULL;
int bytes_returned;
int smb_hdr_len;
__u32 bytes_sent;
WRITE_RSP *pSMBr = NULL;
/*int bytes_returned;*/
unsigned bytes_sent;
__u16 byte_count;

cERROR(1,("write2 at %lld %d bytes",offset,count)); /* BB removeme BB */
rc = small_smb_init(SMB_COM_WRITE_ANDX, 14, tcon, (void **) &pSMB);

if (rc)
return rc;

pSMBr = (WRITE_RSP *)pSMB; /* BB removeme BB */

/* tcon and ses pointer are checked in smb_init */
if (tcon->ses->server == NULL)
return -ECONNABORTED;

pSMB->AndXCommand = 0xFF; /* none */
pSMB->AndXCommand = 0xFF; /* none */
pSMB->Fid = netfid;
pSMB->OffsetLow = cpu_to_le32(offset & 0xFFFFFFFF);
pSMB->OffsetHigh = cpu_to_le32(offset >> 32);
pSMB->Reserved = 0xFFFFFFFF;
pSMB->WriteMode = 0;
pSMB->Remaining = 0;

/* Can increase buffer size if buffer is big enough in some cases - ie
can send more if LARGE_WRITE_X capability returned by the server and if
our buffer is big enough or if we convert to iovecs on socket writes
and eliminate the copy to the CIFS buffer */
if(tcon->ses->capabilities & CAP_LARGE_WRITE_X) {
bytes_sent = min_t(const unsigned int, CIFSMaxBufSize, count);
} else {
bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE)
& ~0xFF;
}

bytes_sent = (tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & ~0xFF;
if (bytes_sent > count)
bytes_sent = count;
pSMB->DataLengthHigh = 0;
pSMB->DataOffset =
cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 4);

byte_count = bytes_sent + 1 /* pad */ ; /* BB fix this for sends > 64K */
pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF);
pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16);
smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */
pSMB->hdr.smb_buf_length += bytes_sent+1;
byte_count = bytes_sent + 1 /* pad */ ;
pSMB->DataLengthLow = cpu_to_le16(bytes_sent);
pSMB->DataLengthHigh = 0;
pSMB->hdr.smb_buf_length += byte_count;
pSMB->ByteCount = cpu_to_le16(byte_count);

rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB, smb_hdr_len,
buf, bytes_sent, &bytes_returned, long_op);
/* rc = SendReceive2(xid, tcon->ses, (struct smb_hdr *) pSMB,
(struct smb_hdr *) pSMBr, buf, buflen, &bytes_returned, long_op); */ /* BB fixme BB */
if (rc) {
cFYI(1, ("Send error in write = %d", rc));
cFYI(1, ("Send error in write2 (large write) = %d", rc));
*nbytes = 0;
} else {
WRITE_RSP * pSMBr = (WRITE_RSP *)pSMB;
*nbytes = le16_to_cpu(pSMBr->CountHigh);
*nbytes = (*nbytes) << 16;
*nbytes += le16_to_cpu(pSMBr->Count);
}
} else
*nbytes = le16_to_cpu(pSMBr->Count);

cifs_small_buf_release(pSMB);

Expand All @@ -1022,8 +1009,6 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,

return rc;
}


#endif /* CIFS_EXPERIMENTAL */

int
Expand Down Expand Up @@ -2411,7 +2396,9 @@ int CIFSFindSingle(const int xid, struct cifsTconInfo *tcon,
if (rc) {
cFYI(1, ("Send error in FindFileDirInfo = %d", rc));
} else { /* decode response */

#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_ffirst);
#endif
/* BB fill in */
}

Expand Down Expand Up @@ -2524,6 +2511,9 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
if (rc == -EAGAIN)
goto findFirstRetry;
} else { /* decode response */
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_ffirst);
#endif
/* BB remember to free buffer if error BB */
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
if(rc == 0) {
Expand Down Expand Up @@ -2637,6 +2627,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
} else
cFYI(1, ("FindNext returned = %d", rc));
} else { /* decode response */
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_fnext);
#endif
rc = validate_t2((struct smb_t2_rsp *)pSMBr);

if(rc == 0) {
Expand Down Expand Up @@ -2706,6 +2699,9 @@ CIFSFindClose(const int xid, struct cifsTconInfo *tcon, const __u16 searchHandle
if (rc) {
cERROR(1, ("Send error in FindClose = %d", rc));
}
#ifdef CONFIG_CIFS_STATS
atomic_inc(&tcon->num_fclose);
#endif
cifs_small_buf_release(pSMB);

/* Since session is dead, search handle closed on server already */
Expand Down
21 changes: 4 additions & 17 deletions trunk/fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,9 @@ static ssize_t cifs_write(struct file *file, const char *write_data,

pTcon = cifs_sb->tcon;

cFYI(1,(" write %d bytes to offset %lld of %s", write_size,
*poffset, file->f_dentry->d_name.name)); /* BB removeme BB */
/* cFYI(1,
(" write %d bytes to offset %lld of %s", write_size,
*poffset, file->f_dentry->d_name.name)); */

if (file->private_data == NULL)
return -EBADF;
Expand Down Expand Up @@ -845,21 +846,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
if (rc != 0)
break;
}
#ifdef CIFS_EXPERIMENTAL
/* BB FIXME We can not sign across two buffers yet */
cERROR(1,("checking signing")); /* BB removeme BB */
if(pTcon->ses->server->secMode &
(SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED) == 0)
rc = CIFSSMBWrite2(xid, pTcon,
open_file->netfid,
min_t(const int, cifs_sb->wsize,
write_size - total_written),
*poffset, &bytes_written,
write_data + total_written,
long_op);
} else
/* BB FIXME fixup indentation of line below */
#endif

rc = CIFSSMBWrite(xid, pTcon,
open_file->netfid,
min_t(const int, cifs_sb->wsize,
Expand Down
4 changes: 3 additions & 1 deletion trunk/fs/cifs/netmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
int
cifs_inet_pton(int address_family, char *cp,void *dst)
{
struct in_addr address;
int value;
int digit;
int i;
Expand Down Expand Up @@ -189,7 +190,8 @@ cifs_inet_pton(int address_family, char *cp,void *dst)
if (value > addr_class_max[end - bytes])
return 0;

*((__be32 *)dst) = *((__be32 *) bytes) | htonl(value);
address.s_addr = *((__be32 *) bytes) | htonl(value);
*((__be32 *)dst) = address.s_addr;
return 1; /* success */
}

Expand Down
16 changes: 10 additions & 6 deletions trunk/fs/cifs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ static void fill_in_inode(struct inode *tmp_inode,
tmp_inode->i_data.a_ops = &cifs_addr_ops;

if(isNewInode)
return; /* No sense invalidating pages for new inode since we
have not started caching readahead file data yet */
return; /* No sense invalidating pages for new inode
since have not started caching readahead file
data yet */

if (timespec_equal(&tmp_inode->i_mtime, &local_mtime) &&
(local_size == tmp_inode->i_size)) {
Expand Down Expand Up @@ -536,7 +537,8 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
(rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){
cFYI(1,("calling findnext2"));
rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, &cifsFile->srch_inf);
rc = CIFSFindNext(xid,pTcon,cifsFile->netfid,
&cifsFile->srch_inf);
if(rc)
return -ENOENT;
}
Expand All @@ -555,7 +557,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
cFYI(1,("found entry - pos_in_buf %d",pos_in_buf));
current_entry = cifsFile->srch_inf.srch_entries_start;
for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
/* go entry to next entry figuring out which we need to start with */
/* go entry by entry figuring out which is first */
/* if( . or ..)
skip */
rc = cifs_entry_is_dot(current_entry,cifsFile);
Expand Down Expand Up @@ -721,7 +723,8 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
(FILE_DIRECTORY_INFO *)pfindEntry,&obj_type, rc);
}

rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,tmp_inode->i_ino,obj_type);
rc = filldir(direntry,qstring.name,qstring.len,file->f_pos,
tmp_inode->i_ino,obj_type);
if(rc) {
cFYI(1,("filldir rc = %d",rc));
}
Expand Down Expand Up @@ -906,7 +909,8 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
cifs_save_resume_key(current_entry,cifsFile);
break;
} else
current_entry = nxt_dir_entry(current_entry,end_of_smb);
current_entry = nxt_dir_entry(current_entry,
end_of_smb);
}
kfree(tmp_buf);
break;
Expand Down
Loading

0 comments on commit 4c72a48

Please sign in to comment.