patch-2.3.7 linux/include/linux/fs.h

Next file: linux/include/linux/hpfs_fs_i.h
Previous file: linux/include/linux/fd1772.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.6/linux/include/linux/fs.h linux/include/linux/fs.h
@@ -74,11 +74,11 @@
 
 /* public flags for file_system_type */
 #define FS_REQUIRES_DEV 1 
-#define FS_NO_DCACHE    2 /* Only dcache the necessary things. */
-#define FS_NO_PRELIM    4 /* prevent preloading of dentries, even if
+#define FS_NO_DCACHE	2 /* Only dcache the necessary things. */
+#define FS_NO_PRELIM	4 /* prevent preloading of dentries, even if
 			   * FS_NO_DCACHE is not set.
 			   */
-#define FS_IBASKET      8 /* FS does callback to free_ibasket() if space gets low. */
+#define FS_IBASKET	8 /* FS does callback to free_ibasket() if space gets low. */
 
 /*
  * These are the fs-independent mount-flags: up to 16 flags are supported
@@ -94,9 +94,9 @@
 #define S_APPEND	256	/* Append-only file */
 #define S_IMMUTABLE	512	/* Immutable file */
 #define MS_NOATIME	1024	/* Do not update access times. */
-#define MS_NODIRATIME   2048    /* Do not update directory access times */
+#define MS_NODIRATIME	2048	/* Do not update directory access times */
 
-#define MS_ODD_RENAME   32768    /* Temporary stuff; will go away as soon
+#define MS_ODD_RENAME	32768	/* Temporary stuff; will go away as soon
 				  * as nfs_rename() will be cleaned up
 				  */
 
@@ -189,7 +189,6 @@
 #define BH_Lock		2	/* 1 if the buffer is locked */
 #define BH_Req		3	/* 0 if the buffer has been invalidated */
 #define BH_Protected	6	/* 1 if the buffer is protected */
-
 /*
  * Try to keep the most commonly used fields in single cache lines (16
  * bytes) to improve performance.  This ordering should be
@@ -218,7 +217,7 @@
 	/* Non-performance-critical data follows. */
 	char * b_data;			/* pointer to data block (1024 bytes) */
 	unsigned int b_list;		/* List that this buffer appears */
-	unsigned long b_flushtime;      /* Time when this (dirty) buffer
+	unsigned long b_flushtime;	/* Time when this (dirty) buffer
 					 * should be written */
 	wait_queue_head_t b_wait;
 	struct buffer_head ** b_pprev;		/* doubly linked list of hash-queue */
@@ -235,30 +234,13 @@
 typedef void (bh_end_io_t)(struct buffer_head *bh, int uptodate);
 void init_buffer(struct buffer_head *, kdev_t, int, bh_end_io_t *, void *);
 
-static inline int buffer_uptodate(struct buffer_head * bh)
-{
-	return test_bit(BH_Uptodate, &bh->b_state);
-}	
-
-static inline int buffer_dirty(struct buffer_head * bh)
-{
-	return test_bit(BH_Dirty, &bh->b_state);
-}
+#define __buffer_state(bh, state)	(((bh)->b_state & (1UL << BH_##state)) != 0)
 
-static inline int buffer_locked(struct buffer_head * bh)
-{
-	return test_bit(BH_Lock, &bh->b_state);
-}
-
-static inline int buffer_req(struct buffer_head * bh)
-{
-	return test_bit(BH_Req, &bh->b_state);
-}
-
-static inline int buffer_protected(struct buffer_head * bh)
-{
-	return test_bit(BH_Protected, &bh->b_state);
-}
+#define buffer_uptodate(bh)	__buffer_state(bh,Uptodate)
+#define buffer_dirty(bh)	__buffer_state(bh,Dirty)
+#define buffer_locked(bh)	__buffer_state(bh,Lock)
+#define buffer_req(bh)		__buffer_state(bh,Req)
+#define buffer_protected(bh)	__buffer_state(bh,Protected)
 
 #define buffer_page(bh)		(mem_map + MAP_NR((bh)->b_data))
 #define touch_buffer(bh)	set_bit(PG_referenced, &buffer_page(bh)->flags)
@@ -357,7 +339,6 @@
 	unsigned long		i_version;
 	unsigned long		i_nrpages;
 	struct semaphore	i_sem;
-	struct semaphore	i_atomic_write;
 	struct inode_operations	*i_op;
 	struct super_block	*i_sb;
 	wait_queue_head_t	i_wait;
@@ -365,22 +346,21 @@
 	struct vm_area_struct	*i_mmap;
 	struct page		*i_pages;
 	struct dquot		*i_dquot[MAXQUOTAS];
+	struct pipe_inode_info	*i_pipe;
 
 	unsigned long		i_state;
 
 	unsigned int		i_flags;
-	unsigned char		i_pipe;
 	unsigned char		i_sock;
 
 	int			i_writecount;
 	unsigned int		i_attr_flags;
 	__u32			i_generation;
 	union {
-		struct pipe_inode_info		pipe_i;
 		struct minix_inode_info		minix_i;
 		struct ext2_inode_info		ext2_i;
 		struct hpfs_inode_info		hpfs_i;
-		struct ntfs_inode_info          ntfs_i;
+		struct ntfs_inode_info		ntfs_i;
 		struct msdos_inode_info		msdos_i;
 		struct umsdos_inode_info	umsdos_i;
 		struct iso_inode_info		isofs_i;
@@ -388,13 +368,13 @@
 		struct sysv_inode_info		sysv_i;
 		struct affs_inode_info		affs_i;
 		struct ufs_inode_info		ufs_i;
-		struct efs_inode_info		efs_i;	   
+		struct efs_inode_info		efs_i;
 		struct romfs_inode_info		romfs_i;
 		struct coda_inode_info		coda_i;
 		struct smb_inode_info		smbfs_i;
 		struct hfs_inode_info		hfs_i;
 		struct adfs_inode_info		adfs_i;
-		struct qnx4_inode_info		qnx4_i;	   
+		struct qnx4_inode_info		qnx4_i;
 		struct socket			socket_i;
 		void				*generic_ip;
 	} u;
@@ -491,10 +471,10 @@
 extern void posix_unblock_lock(struct file_lock *);
 
 struct fasync_struct {
-	int    magic;
-	int    fa_fd;
-	struct fasync_struct	*fa_next; /* singly linked list */
-	struct file 		*fa_file;
+	int	magic;
+	int	fa_fd;
+	struct	fasync_struct	*fa_next; /* singly linked list */
+	struct	file 		*fa_file;
 };
 
 #define FASYNC_MAGIC 0x4601
@@ -547,19 +527,19 @@
 		struct minix_sb_info	minix_sb;
 		struct ext2_sb_info	ext2_sb;
 		struct hpfs_sb_info	hpfs_sb;
-		struct ntfs_sb_info     ntfs_sb;
+		struct ntfs_sb_info	ntfs_sb;
 		struct msdos_sb_info	msdos_sb;
 		struct isofs_sb_info	isofs_sb;
 		struct nfs_sb_info	nfs_sb;
 		struct sysv_sb_info	sysv_sb;
 		struct affs_sb_info	affs_sb;
 		struct ufs_sb_info	ufs_sb;
-		struct efs_sb_info	efs_sb;	   
+		struct efs_sb_info	efs_sb;
 		struct romfs_sb_info	romfs_sb;
 		struct smb_sb_info	smbfs_sb;
 		struct hfs_sb_info	hfs_sb;
 		struct adfs_sb_info	adfs_sb;
-		struct qnx4_sb_info	qnx4_sb;	   
+		struct qnx4_sb_info	qnx4_sb;
 		void			*generic_sbp;
 	} u;
 	/*
@@ -616,13 +596,22 @@
 			struct inode *, struct dentry *);
 	int (*readlink) (struct dentry *, char *,int);
 	struct dentry * (*follow_link) (struct dentry *, struct dentry *, unsigned int);
+	/*
+	 * the order of these functions within the VFS template has been
+	 * changed because SMP locking has changed: from now on all bmap,
+	 * readpage, writepage and flushpage functions are supposed to do
+	 * whatever locking they need to get proper SMP operation - for
+	 * now in most cases this means a lock/unlock_kernel at entry/exit.
+	 * [The new order is also slightly more logical :)]
+	 */
+	int (*bmap) (struct inode *,int);
 	int (*readpage) (struct file *, struct page *);
 	int (*writepage) (struct file *, struct page *);
-	int (*bmap) (struct inode *,int);
+	int (*flushpage) (struct inode *, struct page *, unsigned long);
+
 	void (*truncate) (struct inode *);
 	int (*permission) (struct inode *, int);
 	int (*smap) (struct inode *,int);
-	int (*updatepage) (struct file *, struct page *, unsigned long, unsigned int);
 	int (*revalidate) (struct dentry *);
 };
 
@@ -749,13 +738,11 @@
 
 extern struct file *inuse_filps;
 
-extern void refile_buffer(struct buffer_head *);
 extern void set_writetime(struct buffer_head *, int);
 extern int try_to_free_buffers(struct page *);
+extern void refile_buffer(struct buffer_head * buf);
 
-extern int nr_buffers;
 extern int buffermem;
-extern int nr_buffer_heads;
 
 #define BUF_CLEAN	0
 #define BUF_LOCKED	1	/* Buffers scheduled for write */
@@ -766,21 +753,36 @@
 
 extern inline void mark_buffer_clean(struct buffer_head * bh)
 {
-	if (test_and_clear_bit(BH_Dirty, &bh->b_state)) {
-		if (bh->b_list == BUF_DIRTY)
-			refile_buffer(bh);
-	}
+	if (test_and_clear_bit(BH_Dirty, &bh->b_state))
+		refile_buffer(bh);
 }
 
+extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh, int flag));
+extern void FASTCALL(__atomic_mark_buffer_dirty(struct buffer_head *bh, int flag));
+
+#define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)
+
 extern inline void mark_buffer_dirty(struct buffer_head * bh, int flag)
 {
-	if (!test_and_set_bit(BH_Dirty, &bh->b_state)) {
-		set_writetime(bh, flag);
-		if (bh->b_list != BUF_DIRTY)
-			refile_buffer(bh);
-	}
+	if (!atomic_set_buffer_dirty(bh))
+		__mark_buffer_dirty(bh, flag);
+}
+
+/*
+ * SMP-safe version of the above - does synchronization with
+ * other users of buffer-cache data structures.
+ *
+ * since we test-set the dirty bit in a CPU-atomic way we also
+ * have optimized the common 'redirtying' case away completely.
+ */
+extern inline void atomic_mark_buffer_dirty(struct buffer_head * bh, int flag)
+{
+	if (!atomic_set_buffer_dirty(bh))
+		__atomic_mark_buffer_dirty(bh, flag);
 }
 
+
+extern void balance_dirty(kdev_t);
 extern int check_disk_change(kdev_t);
 extern int invalidate_inodes(struct super_block *);
 extern void invalidate_inode_pages(struct inode *);
@@ -869,12 +871,19 @@
 extern int brw_page(int, struct page *, kdev_t, int [], int, int);
 
 typedef long (*writepage_t)(struct file *, struct page *, unsigned long, unsigned long, const char *);
+typedef int (*fs_getblock_t)(struct inode *, long, int, int *, int *);
+
+/* Generic buffer handling for block filesystems.. */
+extern int block_read_full_page(struct file *, struct page *);
+extern int block_write_full_page (struct file *, struct page *, fs_getblock_t);
+extern int block_write_partial_page (struct file *, struct page *, unsigned long, unsigned long, const char *, fs_getblock_t);
+extern int block_flushpage(struct inode *, struct page *, unsigned long);
 
-extern int generic_readpage(struct file *, struct page *);
 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
 extern ssize_t generic_file_read(struct file *, char *, size_t, loff_t *);
 extern ssize_t generic_file_write(struct file *, const char *, size_t, loff_t *, writepage_t);
 
+
 extern struct super_block *get_super(kdev_t);
 extern void put_super(kdev_t);
 unsigned long generate_cluster(kdev_t, int b[], int);
@@ -898,6 +907,7 @@
 
 extern int block_fsync(struct file *, struct dentry *);
 extern int file_fsync(struct file *, struct dentry *);
+extern int generic_buffer_fdatasync(struct inode *inode, unsigned long start, unsigned long end);
 
 extern int inode_change_ok(struct inode *, struct iattr *);
 extern void inode_setattr(struct inode *, struct iattr *);

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