xfs
[Top] [All Lists]

[PATCH 1/4] add pre-io callback to struct xfs_buf

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/4] add pre-io callback to struct xfs_buf
From: Christoph Hellwig <hch@xxxxxx>
Date: Mon, 15 Sep 2008 03:03:13 +0200
Cc: Dave Chinner <dgc@xxxxxxx>
User-agent: Mutt/1.3.28i
From: Dave Chinner <dgc@xxxxxxx>

Enable a buffer "pre-io" callback to allow the contents of
a buffer to be checked or modified just before writeback occurs.
This is how we'll calculate CRCS on metadata buffers.


Signed-off-by: Dave Chinner <dgc@xxxxxxx>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_buf.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_buf.c       2008-09-15 
02:48:22.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_buf.c    2008-09-15 02:48:24.000000000 
+0200
@@ -1179,6 +1179,14 @@ _xfs_buf_ioapply(
                     (bp->b_flags & XBF_READ_AHEAD) ? READA : READ;
        }
 
+       /*
+        * call out to buffer specific pre-write I/O functions. Used for
+        * validation of buffers and CRC calculations prior to I/O issue.
+        */
+       if (bp->b_io_callback && (bp->b_flags & XBF_WRITE))
+               bp->b_io_callback(bp);
+
+
        /* Special code path for reading a sub page size buffer in --
         * we populate up the whole page, and hence the other metadata
         * in the same page.  This optimization is only valid when the
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_buf.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_buf.h       2008-09-15 
02:48:22.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_buf.h    2008-09-15 02:48:24.000000000 
+0200
@@ -166,6 +166,8 @@ typedef struct xfs_buf {
        unsigned int            b_offset;       /* page offset in first page */
        struct page             **b_pages;      /* array of page pointers */
        struct page             *b_page_array[XB_PAGES]; /* inline pages */
+       void                    (*b_io_callback)(struct xfs_buf *);
+                                               /* pre-write I/O callback */
 #ifdef XFS_BUF_LOCK_TRACKING
        int                     b_last_holder;
 #endif
@@ -228,6 +230,16 @@ static inline int xfs_buf_geterror(xfs_b
 /* Buffer Utility Routines */
 extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
 
+/*
+ * Set the function that should be called immediately prior
+ * to a write I/O being issued on this buffer.
+ */
+static inline void
+xfs_buf_set_io_callback(xfs_buf_t *bp, void (*func)(xfs_buf_t *))
+{
+       bp->b_io_callback = func;
+}
+
 /* Pinning Buffer Storage in Memory */
 extern void xfs_buf_pin(xfs_buf_t *);
 extern void xfs_buf_unpin(xfs_buf_t *);

-- 

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH 1/4] add pre-io callback to struct xfs_buf, Christoph Hellwig <=