lkml.org 
[lkml]   [1997]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectpatch for 2.1.73 smbfs
The attached patch for 2.1.73 smbfs does some minor cleanup and removes
the local find_inode_number() to use the new generic code.

One change worth noting is that I've removed some excessively large
stack buffers in favor of an allocated temp buffer. Previously smbfs had
been reported to be the biggest user of kernel stack space, so this
should improve the situation considerably.

Regards,
Bill--- linux-2.1.73/include/linux/smb_fs_sb.h.old Fri Dec 19 00:33:46 1997
+++ linux-2.1.73/include/linux/smb_fs_sb.h Fri Dec 19 10:13:07 1997
@@ -24,6 +24,7 @@
struct file * sock_file;

struct smb_mount_data *mnt;
+ unsigned char *temp_buf;

/* Connections are counted. Each time a new socket arrives,
* generation is incremented.
--- linux-2.1.73/fs/smbfs/inode.c.old Fri Dec 19 00:22:34 1997
+++ linux-2.1.73/fs/smbfs/inode.c Fri Dec 19 10:18:53 1997
@@ -364,6 +364,7 @@
kill_proc(server->conn_pid, SIGTERM, 1);

kfree(server->mnt);
+ kfree(sb->u.smbfs_sb.temp_buf);
if (server->packet)
smb_vfree(server->packet);
sb->s_dev = 0;
@@ -376,18 +377,16 @@
struct super_block *
smb_read_super(struct super_block *sb, void *raw_data, int silent)
{
- struct smb_mount_data *mnt, *data = (struct smb_mount_data *) raw_data;
- struct smb_fattr root;
- kdev_t dev = sb->s_dev;
+ struct smb_mount_data *mnt;
struct inode *root_inode;
struct dentry *dentry;
+ struct smb_fattr root;

MOD_INC_USE_COUNT;

- if (!data)
+ if (!raw_data)
goto out_no_data;
-
- if (data->version != SMB_MOUNT_VERSION)
+ if (((struct smb_mount_data *) raw_data)->version != SMB_MOUNT_VERSION)
goto out_wrong_data;

lock_super(sb);
@@ -396,7 +395,6 @@
sb->s_blocksize_bits = 10;
sb->s_magic = SMB_SUPER_MAGIC;
sb->s_flags = 0;
- sb->s_dev = dev; /* shouldn't need this ... */
sb->s_op = &smb_sops;

sb->u.smbfs_sb.sock_file = NULL;
@@ -410,10 +408,16 @@
if (!sb->u.smbfs_sb.packet)
goto out_no_mem;

+ /* Allocate the global temp buffer */
+ sb->u.smbfs_sb.temp_buf = kmalloc(SMB_MAXPATHLEN + 20, GFP_KERNEL);
+ if (!sb->u.smbfs_sb.temp_buf)
+ goto out_no_temp;
+
+ /* Allocate the mount data structure */
mnt = kmalloc(sizeof(struct smb_mount_data), GFP_KERNEL);
if (!mnt)
goto out_no_mount;
- *mnt = *data;
+ *mnt = *((struct smb_mount_data *) raw_data);
/* ** temp ** pass config flags in file mode */
mnt->version = (mnt->file_mode >> 9);
#ifdef CONFIG_SMB_WIN95
@@ -450,15 +454,14 @@
return sb;

out_no_root:
- printk(KERN_ERR "smb_read_super: get root inode failed\n");
iput(root_inode);
kfree(sb->u.smbfs_sb.mnt);
out_no_mount:
+ kfree(sb->u.smbfs_sb.temp_buf);
+out_no_temp:
smb_vfree(sb->u.smbfs_sb.packet);
- goto out_unlock;
out_no_mem:
- printk("smb_read_super: could not alloc packet\n");
-out_unlock:
+ printk(KERN_ERR "smb_read_super: allocation failure\n");
unlock_super(sb);
goto out_fail;
out_wrong_data:
--- linux-2.1.73/fs/smbfs/dir.c.old Fri Dec 19 00:22:34 1997
+++ linux-2.1.73/fs/smbfs/dir.c Fri Dec 19 10:59:37 1997
@@ -74,40 +74,6 @@
return -EISDIR;
}

-/*
- * Check whether a dentry already exists for the given name,
- * and return the inode number if it has an inode. This is
- * needed to keep getcwd() working.
- */
-static ino_t
-find_inode_number(struct dentry *dir, struct qstr *name)
-{
- struct dentry * dentry;
- ino_t ino = 0;
-
- /*
- * Check for a fs-specific hash function. Note that we must
- * calculate the standard hash first, as the d_op->d_hash()
- * routine may choose to leave the hash value unchanged.
- */
- name->hash = full_name_hash(name->name, name->len);
- if (dir->d_op && dir->d_op->d_hash)
- {
- if (dir->d_op->d_hash(dir, name) != 0)
- goto out;
- }
-
- dentry = d_lookup(dir, name);
- if (dentry)
- {
- if (dentry->d_inode)
- ino = dentry->d_inode->i_ino;
- dput(dentry);
- }
-out:
- return ino;
-}
-
static int
smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
@@ -193,7 +159,7 @@

/*
* Note: in order to allow the smbclient process to open the
- * mount point, we don't revalidate for the connection pid.
+ * mount point, we don't revalidate if conn_pid is NULL.
*/
static int
smb_dir_open(struct inode *dir, struct file *file)
@@ -218,8 +184,6 @@

if (server->conn_pid)
error = smb_revalidate_inode(dir);
- else
- printk("smb_dir_open: smbclient process\n");
return error;
}

--- linux-2.1.73/fs/smbfs/proc.c.old Fri Dec 19 00:22:34 1997
+++ linux-2.1.73/fs/smbfs/proc.c Fri Dec 19 10:13:07 1997
@@ -975,7 +975,7 @@
smb_close_fileid(struct dentry *dentry, __u16 fileid)
{
struct smb_sb_info *server = server_from_dentry(dentry);
- int result = 0;
+ int result;

smb_lock_server(server);
result = smb_proc_close(server, fileid, CURRENT_TIME);
@@ -1270,6 +1270,9 @@
/*
* Note that we are now returning the name as a reference to avoid
* an extra copy, and that the upper/lower casing is done in place.
+ *
+ * Bugs Noted:
+ * (1) Pathworks servers may pad the name with extra spaces.
*/
static __u8 *
smb_decode_dirent(struct smb_sb_info *server, __u8 *p,
@@ -1442,10 +1445,6 @@
*
* Bugs Noted:
* (1) Win NT 4.0 appends a null byte to names and counts it in the length!
- * (2) When using Info Level 1 Win NT 4.0 truncates directory listings
- * for certain patterns of names and/or lengths. The breakage pattern is
- * completely reproducible and can be toggled by the addition of a single
- * file to the directory. (E.g. echo hi >foo breaks, rm -f foo works.)
*/
static char *
smb_decode_long_dirent(struct smb_sb_info *server, char *p,
@@ -1509,24 +1508,29 @@
return result;
}

+/*
+ * Bugs Noted:
+ * (1) When using Info Level 1 Win NT 4.0 truncates directory listings
+ * for certain patterns of names and/or lengths. The breakage pattern
+ * is completely reproducible and can be toggled by the creation of a
+ * single file. (E.g. echo hi >foo breaks, rm -f foo works.)
+ */
static int
smb_proc_readdir_long(struct smb_sb_info *server, struct dentry *dir, int fpos,
void *cachep)
{
+ char *p, *mask, *lastname, *param = server->temp_buf;
+ __u16 command;
+ int first, entries, entries_seen;
+
/* Both NT and OS/2 accept info level 1 (but see note below). */
int info_level = 1;
const int max_matches = 512;

- char *p, *mask, *lastname;
- int first, entries, entries_seen;
-
unsigned char *resp_data = NULL;
unsigned char *resp_param = NULL;
int resp_data_len = 0;
int resp_param_len = 0;
-
- __u16 command;
-
int ff_resume_key = 0; /* this isn't being used */
int ff_searchcount = 0;
int ff_eos = 0;
@@ -1534,8 +1538,6 @@
int ff_dir_handle = 0;
int loop_count = 0;
int mask_len, i, result;
-
- char param[12 + SMB_MAXPATHLEN + 2]; /* too long for the stack! */
static struct qstr star = { "*", 1, 0 };

/*
@@ -1553,7 +1555,7 @@
/*
* Encode the initial path
*/
- mask = &(param[12]);
+ mask = param + 12;
mask_len = smb_encode_path(server, mask, dir, &star) - mask;
first = 1;
#ifdef SMBFS_DEBUG_VERBOSE
@@ -1643,11 +1645,6 @@
entries = -smb_errno(server);
break;
}
-#ifdef SMBFS_PARANOIA
-if (resp_data + resp_data_len > server->packet + server->packet_size)
-printk("s_p_r_l: data past packet end! data=%p, len=%d, packet=%p\n",
-resp_data + resp_data_len, resp_data_len, server->packet + server->packet_size);
-#endif

/* parse out some important return info */
if (first != 0)
@@ -1799,15 +1796,14 @@
smb_proc_getattr_trans2(struct smb_sb_info *server, struct dentry *dir,
struct smb_fattr *attr)
{
- char *p;
- int result;
+ char *p, *param = server->temp_buf;
__u16 date, time;
int off_date = 0, off_time = 2;
unsigned char *resp_data = NULL;
unsigned char *resp_param = NULL;
int resp_data_len = 0;
int resp_param_len = 0;
- char param[SMB_MAXPATHLEN + 20]; /* too big for the stack! */
+ int result;

retry:
WSET(param, 0, 1); /* Info level SMB_INFO_STANDARD */
@@ -2023,14 +2019,12 @@
struct dentry *dir, struct smb_fattr *fattr)
{
__u16 date, time;
- char *p;
- int result;
-
+ char *p, *param = server->temp_buf;
unsigned char *resp_data = NULL;
unsigned char *resp_param = NULL;
int resp_data_len = 0;
int resp_param_len = 0;
- char param[SMB_MAXPATHLEN + 20]; /* too long for the stack! */
+ int result;
char data[26];

retry:
@@ -2082,7 +2076,8 @@
* Bugs Noted:
* (1) Win 95 doesn't support the TRANSACT2_SETFILEINFO message
* with info level 1 (INFO_STANDARD).
- * (2) Under the core protocol apparently the only way to set the
+ * (2) Win 95 seems not to support setting directory timestamps.
+ * (3) Under the core protocol apparently the only way to set the
* timestamp is to open and close the file.
*/
int
@@ -2092,7 +2087,7 @@
struct inode *inode = dentry->d_inode;
int result;

-#ifdef SMBFS_DEBUG_TIMESTAMP
+#ifdef SMBFS_DEBUG_VERBOSE
printk("smb_proc_settime: setting %s/%s, open=%d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, smb_is_open(inode));
#endif
@@ -2127,16 +2122,6 @@
}
}

-#if 1 /* temporary */
- if (result)
- {
-printk("smb_proc_settime: %s/%s failed, open=%d, res=%d, rcls=%d, err=%d\n",
-dentry->d_parent->d_name.name, dentry->d_name.name, smb_is_open(inode),
-result, server->rcls, server->err);
- /* squash errors for now */
- result = 0;
- }
-#endif
smb_unlock_server(server);
return result;
}
\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.086 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site