Browse Source

[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 <sfrench@us.ibm.com>
cc: jra@samba.org
cc: shaggy@us.ibm.com
Steve French 18 years ago
parent
commit
9a0c8230e8
2 changed files with 16 additions and 4 deletions
  1. 9 3
      fs/cifs/file.c
  2. 7 1
      fs/cifs/smbdes.c

+ 9 - 3
fs/cifs/file.c

@@ -1146,7 +1146,7 @@ static int cifs_writepages(struct address_space *mapping,
 	pgoff_t end;
 	pgoff_t end;
 	pgoff_t index;
 	pgoff_t index;
  	int range_whole = 0;
  	int range_whole = 0;
-	struct kvec iov[32];
+	struct kvec * iov;
 	int len;
 	int len;
 	int n_iov = 0;
 	int n_iov = 0;
 	pgoff_t next;
 	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) && (cifs_sb->tcon->ses->server))
 		if(cifs_sb->tcon->ses->server->secMode &
 		if(cifs_sb->tcon->ses->server->secMode &
                           (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
                           (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
-			if(!experimEnabled)
+			if(!experimEnabled) 
 				return generic_writepages(mapping, wbc);
 				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?
 	 * 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 it is, we should test it again after we do I/O
 	 */
 	 */
 	if (wbc->nonblocking && bdi_write_congested(bdi)) {
 	if (wbc->nonblocking && bdi_write_congested(bdi)) {
 		wbc->encountered_congestion = 1;
 		wbc->encountered_congestion = 1;
+		kfree(iov);
 		return 0;
 		return 0;
 	}
 	}
 
 
@@ -1345,7 +1351,7 @@ retry:
 		mapping->writeback_index = index;
 		mapping->writeback_index = index;
 
 
 	FreeXid(xid);
 	FreeXid(xid);
-
+	kfree(iov);
 	return rc;
 	return rc;
 }
 }
 
 

+ 7 - 1
fs/cifs/smbdes.c

@@ -196,7 +196,7 @@ dohash(char *out, char *in, char *key, int forw)
 	char c[28];
 	char c[28];
 	char d[28];
 	char d[28];
 	char *cd;
 	char *cd;
-	char ki[16][48];
+	char (*ki)[48];
 	char *pd1;
 	char *pd1;
 	char l[32], r[32];
 	char l[32], r[32];
 	char *rl;
 	char *rl;
@@ -206,6 +206,10 @@ dohash(char *out, char *in, char *key, int forw)
 	if(pk1 == NULL)
 	if(pk1 == NULL)
 		return;
 		return;
 
 
+	ki = kmalloc(16*48, GFP_KERNEL);
+	if(ki == NULL)
+		return;
+
 	cd = pk1 + 56;
 	cd = pk1 + 56;
 	pd1= cd  + 56;
 	pd1= cd  + 56;
 	rl = pd1 + 64;
 	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);
 		er = kmalloc(48+48+32+32+32, GFP_KERNEL);
 		if(er == NULL) {
 		if(er == NULL) {
 			kfree(pk1);
 			kfree(pk1);
+			kfree(ki);
 			return;
 			return;
 		}
 		}
 		erk = er+48;
 		erk = er+48;
@@ -290,6 +295,7 @@ dohash(char *out, char *in, char *key, int forw)
 
 
 	permute(out, rl, perm6, 64);
 	permute(out, rl, perm6, 64);
 	kfree(pk1);
 	kfree(pk1);
+	kfree(ki);
 }
 }
 
 
 static void
 static void