patch-2.4.2 linux/include/linux/smb_fs.h

Next file: linux/include/linux/smb_fs_i.h
Previous file: linux/include/linux/smb.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.1/linux/include/linux/smb_fs.h linux/include/linux/smb_fs.h
@@ -20,23 +20,31 @@
 /* __kernel_uid_t can never change, so we have to use __kernel_uid32_t */
 #define	SMB_IOC_GETMOUNTUID32		_IOR('u', 3, __kernel_uid32_t)
 
+
 #ifdef __KERNEL__
 
+#include <linux/pagemap.h>
+#include <linux/vmalloc.h>
+#include <linux/smb_mount.h>
 #include <asm/unaligned.h>
 
+
+/* macro names are short for word, double-word, long value (?) */
 #define WVAL(buf,pos) \
-(le16_to_cpu(get_unaligned((__u16 *)((__u8 *)(buf) + (pos)))))
+	(le16_to_cpu(get_unaligned((u16 *)((u8 *)(buf) + (pos)))))
 #define DVAL(buf,pos) \
-(le32_to_cpu(get_unaligned((__u32 *)((__u8 *)(buf) + (pos)))))
+	(le32_to_cpu(get_unaligned((u32 *)((u8 *)(buf) + (pos)))))
+#define LVAL(buf,pos) \
+	(le64_to_cpu(get_unaligned((u64 *)((u8 *)(buf) + (pos)))))
 #define WSET(buf,pos,val) \
-put_unaligned(cpu_to_le16((__u16)(val)), (__u16 *)((__u8 *)(buf) + (pos)))
+	put_unaligned(cpu_to_le16((u16)(val)), (u16 *)((u8 *)(buf) + (pos)))
 #define DSET(buf,pos,val) \
-put_unaligned(cpu_to_le32((__u32)(val)), (__u32 *)((__u8 *)(buf) + (pos)))
+	put_unaligned(cpu_to_le32((u32)(val)), (u32 *)((u8 *)(buf) + (pos)))
+#define LSET(buf,pos,val) \
+	put_unaligned(cpu_to_le64((u64)(val)), (u64 *)((u8 *)(buf) + (pos)))
 
 /* where to find the base of the SMB packet proper */
-#define smb_base(buf) ((__u8 *)(((__u8 *)(buf))+4))
-
-#include <linux/vmalloc.h>
+#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
 
 #ifdef DEBUG_SMB_MALLOC
 
@@ -70,7 +78,6 @@
 /*
  * Flags for the in-memory inode
  */
-#define SMB_F_CACHEVALID	0x01	/* directory cache valid */
 #define SMB_F_LOCALWRITE	0x02	/* file modified locally */
 
 
@@ -89,8 +96,54 @@
 #define SMB_CAP_LARGE_READX      0x4000
 
 
-/* linux/fs/smbfs/mmap.c */
-int smb_mmap(struct file *, struct vm_area_struct *);
+/*
+ * This is the time we allow an inode, dentry or dir cache to live. It is bad
+ * for performance to have shorter ttl on an inode than on the cache. It can
+ * cause refresh on each inode for a dir listing ... one-by-one
+ */
+#define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
+
+static inline void
+smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
+{
+	dentry->d_time = jiffies - SMB_MAX_AGE(server);
+}
+
+struct smb_cache_head {
+	time_t		mtime;	/* unused */
+	unsigned long	time;	/* cache age */
+	unsigned long	end;	/* last valid fpos in cache */
+	int		eof;
+};
+
+#define SMB_DIRCACHE_SIZE	((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
+union smb_dir_cache {
+	struct smb_cache_head   head;
+	struct dentry           *dentry[SMB_DIRCACHE_SIZE];
+};
+
+#define SMB_FIRSTCACHE_SIZE	((int)((SMB_DIRCACHE_SIZE * \
+	sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
+	sizeof(struct dentry *)))
+
+#define SMB_DIRCACHE_START      (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
+
+struct smb_cache_control {
+	struct  smb_cache_head		head;
+	struct  page			*page;
+	union   smb_dir_cache		*cache;
+	unsigned long			fpos, ofs;
+	int				filled, valid, idx;
+};
+
+static inline int
+smb_is_open(struct inode *i)
+{
+	return (i->u.smbfs_i.open == SMB_SERVER(i)->generation);
+}
+
+
+/* FIXME! the prototype list is probably not correct. Automate? */
 
 /* linux/fs/smbfs/file.c */
 extern struct inode_operations smb_file_inode_operations;
@@ -100,6 +153,7 @@
 /* linux/fs/smbfs/dir.c */
 extern struct inode_operations smb_dir_inode_operations;
 extern struct file_operations smb_dir_operations;
+void smb_new_dentry(struct dentry *dentry);
 void smb_renew_times(struct dentry *);
 
 /* linux/fs/smbfs/ioctl.c */
@@ -108,16 +162,15 @@
 /* linux/fs/smbfs/inode.c */
 struct super_block *smb_read_super(struct super_block *, void *, int);
 void smb_get_inode_attr(struct inode *, struct smb_fattr *);
+void smb_set_inode_attr(struct inode *, struct smb_fattr *);
 void smb_invalidate_inodes(struct smb_sb_info *);
 int  smb_revalidate_inode(struct dentry *);
 int  smb_notify_change(struct dentry *, struct iattr *);
-unsigned long smb_invent_inos(unsigned long);
 struct inode *smb_iget(struct super_block *, struct smb_fattr *);
 
 /* linux/fs/smbfs/proc.c */
 int smb_setcodepage(struct smb_sb_info *server, struct smb_nls_codepage *cp);
 __u32 smb_len(unsigned char *);
-__u8 *smb_encode_smb_length(__u8 *, __u32);
 __u8 *smb_setup_header(struct smb_sb_info *, __u8, __u16, __u16);
 int smb_get_rsize(struct smb_sb_info *);
 int smb_get_wsize(struct smb_sb_info *);
@@ -133,32 +186,21 @@
 int smb_proc_mkdir(struct dentry *);
 int smb_proc_rmdir(struct dentry *);
 int smb_proc_unlink(struct dentry *);
-int smb_proc_readdir(struct dentry *, int, void *);
+int smb_proc_readdir(struct file *filp, void *dirent, filldir_t filldir,
+		     struct smb_cache_control *ctl);
 int smb_proc_getattr(struct dentry *, struct smb_fattr *);
 int smb_proc_setattr(struct dentry *, struct smb_fattr *);
 int smb_proc_settime(struct dentry *, struct smb_fattr *);
 int smb_proc_dskattr(struct super_block *, struct statfs *);
-int smb_proc_reconnect(struct smb_sb_info *);
-int smb_proc_connect(struct smb_sb_info *);
 int smb_proc_disconnect(struct smb_sb_info *);
 int smb_proc_trunc(struct smb_sb_info *, __u16, __u32);
 void smb_init_root_dirent(struct smb_sb_info *, struct smb_fattr *);
 
-static inline int
-smb_is_open(struct inode *i)
-{
-	return (i->u.smbfs_i.open == SMB_SERVER(i)->generation);
-}
-
 /* linux/fs/smbfs/sock.c */
 int smb_round_length(int);
 int smb_valid_socket(struct inode *);
 void smb_close_socket(struct smb_sb_info *);
-int smb_release(struct smb_sb_info *server);
-int smb_connect(struct smb_sb_info *server);
 int smb_request(struct smb_sb_info *server);
-int smb_request_read_raw(struct smb_sb_info *, unsigned char *, int);
-int smb_request_write_raw(struct smb_sb_info *, unsigned const char *, int);
 int smb_catch_keepalive(struct smb_sb_info *server);
 int smb_dont_catch_keepalive(struct smb_sb_info *server);
 int smb_trans2_request(struct smb_sb_info *server, __u16 trans2_command,
@@ -169,69 +211,14 @@
 
 /* fs/smbfs/cache.c */
 
-/*
- * The cache index describes the pages mapped starting
- * at offset PAGE_SIZE.  We keep only a minimal amount
- * of information here.
- */
-struct cache_index {
-	unsigned short num_entries;
-	unsigned short space;
-	struct cache_block * block;
-};
-
-#define NINDEX (PAGE_SIZE-64)/sizeof(struct cache_index)
-/*
- * The cache head is mapped as the page at offset 0.
- */
-struct cache_head {
-	int	valid;
-	int	status;		/* error code or 0 */
-	int	entries;	/* total entries */
-	int	pages;		/* number of data pages */
-	int	idx;		/* index of current data page */
-	struct cache_index index[NINDEX];
-};
-
-/*
- * An array of cache_entry structures holds information
- * for each object in the cache_block.
- */
-struct cache_entry {
-	ino_t ino;
-	unsigned short namelen;
-	unsigned short offset;
-};
-
-/*
- * The cache blocks hold the actual data.  The entry table grows up
- * while the names grow down, and we have space until they meet.
- */
-struct cache_block {
-	union {
-		struct cache_entry table[1];
-		char	names[PAGE_SIZE];
-	} cb_data;
-};
-
-/*
- * To return an entry, we can pass a reference to the
- * name instead of having to copy it.
- */
-struct cache_dirent {
-	ino_t ino;
-	unsigned long pos;
-	int len;
-	char * name;
-};
+void smb_invalid_dir_cache(struct inode * dir);
+void smb_invalidate_dircache_entries(struct dentry *parent);
+struct dentry * smb_dget_fpos(struct dentry *dentry, struct dentry *parent, 
+			      unsigned long fpos);
+int smb_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
+		   struct smb_cache_control *ctrl, struct qstr *qname,
+		   struct smb_fattr *entry);
 
-struct cache_head * smb_get_dircache(struct dentry *);
-void smb_init_dircache(struct cache_head *);
-void smb_free_dircache(struct cache_head *);
-int  smb_refill_dircache(struct cache_head *, struct dentry *);
-void smb_add_to_cache(struct cache_head *, struct cache_dirent *, off_t);
-int  smb_find_in_cache(struct cache_head *, off_t, struct cache_dirent *);
-void smb_invalid_dir_cache(struct inode *);
 
 #endif /* __KERNEL__ */
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)