From 030e9d8147491a9d2fe1b67882a3720fcf8b95f7 Mon Sep 17 00:00:00 2001 From: Steve French Date: Thu, 1 Feb 2007 04:27:59 +0000 Subject: [CIFS] lseek polling returned stale EOF Fixes Samba bug 4362 Discovered by Jeremy Allison Clipper database polls on EOF via lseek and can get stale EOF when file is open on different client Signed-off-by: Jeremy Allison Signed-off-by: Steve French --- fs/cifs/cifsfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 10c90294cd1..93ef09971d2 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -511,7 +511,15 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) { /* origin == SEEK_END => we must revalidate the cached file length */ if (origin == SEEK_END) { - int retval = cifs_revalidate(file->f_path.dentry); + int retval; + + /* some applications poll for the file length in this strange + way so we must seek to end on non-oplocked files by + setting the revalidate time to zero */ + if(file->f_path.dentry->d_inode) + CIFS_I(file->f_path.dentry->d_inode)->time = 0; + + retval = cifs_revalidate(file->f_path.dentry); if (retval < 0) return (loff_t)retval; } -- cgit v1.2.3 From 9a0c8230e84898ed27f790408805e33fa482b2f9 Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 2 Feb 2007 04:21:57 +0000 Subject: [CIFS] Reduce cifs stack space usage The two cifs functions that used the most stack according to "make checkstack" have been changed to use less stack. Thanks to jra and Shaggy for helpful ideas Signed-off-by: Steve French cc: jra@samba.org cc: shaggy@us.ibm.com --- fs/cifs/file.c | 12 +++++++++--- fs/cifs/smbdes.c | 8 +++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 8a49b2e77d3..e9dcf5ee29a 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1146,7 +1146,7 @@ static int cifs_writepages(struct address_space *mapping, pgoff_t end; pgoff_t index; int range_whole = 0; - struct kvec iov[32]; + struct kvec * iov; int len; int n_iov = 0; pgoff_t next; @@ -1171,15 +1171,21 @@ static int cifs_writepages(struct address_space *mapping, if((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server)) if(cifs_sb->tcon->ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) - if(!experimEnabled) + if(!experimEnabled) return generic_writepages(mapping, wbc); + iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); + if(iov == NULL) + return generic_writepages(mapping, wbc); + + /* * BB: Is this meaningful for a non-block-device file system? * If it is, we should test it again after we do I/O */ if (wbc->nonblocking && bdi_write_congested(bdi)) { wbc->encountered_congestion = 1; + kfree(iov); return 0; } @@ -1345,7 +1351,7 @@ retry: mapping->writeback_index = index; FreeXid(xid); - + kfree(iov); return rc; } diff --git a/fs/cifs/smbdes.c b/fs/cifs/smbdes.c index 7a1b2b961ec..1a4a395c937 100644 --- a/fs/cifs/smbdes.c +++ b/fs/cifs/smbdes.c @@ -196,7 +196,7 @@ dohash(char *out, char *in, char *key, int forw) char c[28]; char d[28]; char *cd; - char ki[16][48]; + char (*ki)[48]; char *pd1; char l[32], r[32]; char *rl; @@ -206,6 +206,10 @@ dohash(char *out, char *in, char *key, int forw) if(pk1 == NULL) return; + ki = kmalloc(16*48, GFP_KERNEL); + if(ki == NULL) + return; + cd = pk1 + 56; pd1= cd + 56; rl = pd1 + 64; @@ -243,6 +247,7 @@ dohash(char *out, char *in, char *key, int forw) er = kmalloc(48+48+32+32+32, GFP_KERNEL); if(er == NULL) { kfree(pk1); + kfree(ki); return; } erk = er+48; @@ -290,6 +295,7 @@ dohash(char *out, char *in, char *key, int forw) permute(out, rl, perm6, 64); kfree(pk1); + kfree(ki); } static void -- cgit v1.2.3 From 914afcf55ae2621a3c5930e8c458d4ae8636c469 Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 2 Feb 2007 14:42:12 +0000 Subject: [CIFS] Missing free in error path Thanks to jra for pointing this out Signed-off-by: Jeremy Allison Signed-off-by: Steve French --- fs/cifs/smbdes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smbdes.c b/fs/cifs/smbdes.c index 1a4a395c937..1b1daf63f06 100644 --- a/fs/cifs/smbdes.c +++ b/fs/cifs/smbdes.c @@ -207,8 +207,10 @@ dohash(char *out, char *in, char *key, int forw) return; ki = kmalloc(16*48, GFP_KERNEL); - if(ki == NULL) + if(ki == NULL) { + kfree(pk1); return; + } cd = pk1 + 56; pd1= cd + 56; -- cgit v1.2.3 From a850790f6c903f1a89d0dbf953946d231df3fe6b Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 6 Feb 2007 20:43:30 +0000 Subject: [CIFS] Minor cleanup Missing tab. Missing entry in changelog Signed-off-by: Steve French --- fs/cifs/CHANGES | 2 ++ fs/cifs/readdir.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index d04d2f7448d..85e3850bf2c 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES @@ -1,6 +1,8 @@ Version 1.47 ------------ Fix oops in list_del during mount caused by unaligned string. +Seek to SEEK_END forces check for update of file size for non-cached +files. Version 1.46 ------------ diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 99dfb5337e3..782940be550 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -156,9 +156,9 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, 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)); + tmp_inode->i_ctime = cnvrtDosUnixTm( + le16_to_cpu(pfindData->LastWriteDate), + le16_to_cpu(pfindData->LastWriteTime)); AdjustForTZ(cifs_sb->tcon, tmp_inode); attr = le16_to_cpu(pfindData->Attributes); allocation_size = le32_to_cpu(pfindData->AllocationSize); -- cgit v1.2.3