Skip to contentSkip to conversation

Fix CacheFS barrier handling and other kernel discrepancies

PATCH New David Howells 1 participant 1 message Sep 23, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix CacheFS barrier handling and other kernel discrepancies

The attached patch fixes some discrepancies between the latest version of the kernel and CacheFS; namely: BIO_RW_BARRIER may now cause an error if the underlying blockdev doesn't support it and i_op->write_inode() now returns an error.

---

diffstat cachefs-269rc2mm1.diff

 cachefs-int.h |    8 +++--
 inode.c       |    3 +-
 journal.c     |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 super.c       |    9 ++++--
 4 files changed, 94 insertions(+), 9 deletions(-)
fs/cachefs/cachefs-int.h +5 -3
diff -uNrp linux-2.6.9-rc2-mm1/fs/cachefs/cachefs-int.h linux-2.6.9-rc2-mm1-afskey/fs/cachefs/cachefs-int.h
@@ -73,6 +73,8 @@ struct cachefs_super
 #define CACHEFS_SUPER_WITHDRAWN		4		/* T if cache has been withdrawn */
 #define CACHEFS_SUPER_REPLAYING_UJNL	5		/* T if replaying u-journal */
 
+	int				bio_wr_barrier;	/* command to submit a write barrier BIO */
+
 	/* index management */
 	struct list_head		ino_list;	/* list of data/index inodes */
 	spinlock_t			ino_list_lock;
@@ -154,8 +156,6 @@ struct cachefs_super
 	wait_queue_head_t		batch_timer_wq;	/* batch timer wait queue */
 	wait_queue_head_t		batch_sync_wq;	/* batch sync wait queue */
 
-	struct list_head		jnld_link;	/* journalling daemon list */
-
 	/* validity journal tracking */
 	unsigned long			*vjnl_map;	/* bitmap of free entries (1 page) */
 	unsigned			vjnl_count;	/* number of free entries */
@@ -200,6 +200,8 @@ extern void cachefs_recycle_transfer_sta
 extern void cachefs_recycle_reclaim(struct cachefs_super *super);
 extern void cachefs_recycle_unallocate_data_block(struct cachefs_super *super);
 
+extern int cachefs_ujnl_check_barrier_cap(struct cachefs_super *super);
+
 /*****************************************************************************/
 /*
  * block management record
@@ -384,7 +386,7 @@ extern struct file_operations cachefs_st
 
 extern struct cachefs_inode *cachefs_iget(struct cachefs_super *super,
 					  ino_t ino);
-extern void cachefs_write_inode(struct inode *_inode, int sync);
+extern int cachefs_write_inode(struct inode *_inode, int sync);
 extern void cachefs_clear_inode(struct inode *vfs_inode);
 
 static inline struct cachefs_inode *cachefs_igrab(struct cachefs_inode *iinode)
fs/cachefs/inode.c +2 -1
diff -uNrp linux-2.6.9-rc2-mm1/fs/cachefs/inode.c linux-2.6.9-rc2-mm1-afskey/fs/cachefs/inode.c
@@ -366,9 +366,10 @@ struct cachefs_inode *cachefs_iget(struc
  * - don't use generic_file_write() to write out the meta-data file's meta-data
  *   as it updates the mtime & ctime and marks the inode dirty again
  */
-void cachefs_write_inode(struct inode *vfs_inode, int sync)
+int cachefs_write_inode(struct inode *vfs_inode, int sync)
 {
 	_enter("{sb=%p ino=%lu},%d", vfs_inode->i_sb, vfs_inode->i_ino, sync);
+	return 0;
 
 } /* end cachefs_write_inode() */
 
fs/cachefs/journal.c +80 -3

104 lines not on this page · raw message

fs/cachefs/super.c +7 -2
diff -uNrp linux-2.6.9-rc2-mm1/fs/cachefs/super.c linux-2.6.9-rc2-mm1-afskey/fs/cachefs/super.c
@@ -297,7 +297,6 @@ static int cachefs_fill_super(struct sup
 	INIT_LIST_HEAD(&super->ujnl_replayq);
 
 	spin_lock_init(&super->njalt_lock);
-	INIT_LIST_HEAD(&super->jnld_link);
 
 	init_MUTEX(&super->batch_sem);
 	init_MUTEX(&super->batch_uj_sem);
@@ -396,12 +395,19 @@ static int cachefs_fill_super(struct sup
 	ret = -EROFS;
 	if (bdev_read_only(sb->s_bdev)) {
 		printk("CacheFS: blockdev read-only\n");
+		goto error;
 	}
 
 	if (sb->s_flags & MS_RDONLY) {
 		printk("CacheFS: filesystem mounted read-only\n");
+		goto error;
 	}
 
+	/* check for barrier capability on the blockdev */
+	ret = cachefs_ujnl_check_barrier_cap(super);
+	if (ret < 0)
+		goto error;
+
 	/* replay the journal if the cache was initialised */
 	super->ujnl_jsof = super->layout->bix_ujournal;
 	super->ujnl_jsof <<= (PAGE_SHIFT - super->sb->s_blocksize_bits);
@@ -794,7 +800,6 @@ static void cachefs_put_super(struct sup
 
 	DECLARE_WAITQUEUE(myself, current);
 
-	printk("\n\n");
 	_enter("{%p}", super);
 
 	BUG_ON(!super);