From: dragos.tatulea@intel.com
To: linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, cjb@laptop.org
Cc: kirill.shutemov@linux.intel.com, irina.tirdea@intel.com,
octavian.purdila@intel.com, tony.luck@intel.com,
keescook@chromium.org, dragos.tatulea@gmail.com,
Adrian Hunter <adrian.hunter@intel.com>
Subject: [PATCH v2 05/26] block: add panic write
Date: Thu, 8 Nov 2012 15:06:03 +0200 [thread overview]
Message-ID: <1352379984-18381-6-git-send-email-dragos.tatulea@intel.com> (raw)
In-Reply-To: <1352379984-18381-1-git-send-email-dragos.tatulea@intel.com>
From: Adrian Hunter <adrian.hunter@intel.com>
Add a small interface to allow block devices to attempt to write
during an oops or panic.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
drivers/block/Kconfig | 3 ++
include/linux/blkdev.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/genhd.h | 3 ++
3 files changed, 83 insertions(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index af5b325..922cfd6 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -554,4 +554,7 @@ config BLK_DEV_OOPS
See <file:Documentation/blockdev/blkoops.txt> for more information.
+config BLK_DEV_PANIC_WRITE
+ bool
+
endif # BLK_DEV
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1756001..bedfaab 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1461,6 +1461,83 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g)
#endif /* CONFIG_BLK_DEV_INTEGRITY */
+#ifdef CONFIG_BLK_DEV_PANIC_WRITE
+
+/**
+ * struct panic_write_operations - operations to support writing during an oops
+ * or panic.
+ * @init: allocate resources
+ * @cleanup: release resources
+ * @write: called in an oops or panic context to write data
+ * @flush: called in an oops or panic context to finish write operations
+ *
+ * @write may need resources that cannot be allocated in a panic or oops
+ * context. @init can be used to allocate those resources in advance.
+ * @cleanup is called if panic writing becomes disabled.
+ */
+struct panic_write_operations {
+ int (*init)(struct block_device *);
+ void (*cleanup)(struct block_device *);
+ int (*write)(struct block_device *, sector_t, void *, unsigned long);
+ int (*flush)(struct block_device *);
+};
+
+static inline int blk_panic_init(struct block_device *bdev)
+{
+ if (!bdev->bd_disk->pwops || !bdev->bd_disk->pwops->write)
+ return -EOPNOTSUPP;
+ if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->init)
+ return bdev->bd_disk->pwops->init(bdev);
+ return 0;
+}
+
+static inline void blk_panic_cleanup(struct block_device *bdev)
+{
+ if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->cleanup)
+ bdev->bd_disk->pwops->cleanup(bdev);
+}
+
+static inline int blk_panic_write(struct block_device *bdev, sector_t sect,
+ void *addr, unsigned long len)
+{
+ if (!bdev->bd_disk->pwops || !bdev->bd_disk->pwops->write)
+ return -EOPNOTSUPP;
+ if (bdev != bdev->bd_contains)
+ sect += bdev->bd_part->start_sect;
+ return bdev->bd_disk->pwops->write(bdev, sect, addr, len);
+}
+
+static inline int blk_panic_flush(struct block_device *bdev)
+{
+ if (bdev->bd_disk->pwops && bdev->bd_disk->pwops->flush)
+ return bdev->bd_disk->pwops->flush(bdev);
+ return 0;
+}
+
+#else
+
+static inline int blk_panic_init(struct block_device *bdev)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline void blk_panic_cleanup(struct block_device *bdev)
+{
+}
+
+static inline int blk_panic_write(struct block_device *bdev, sector_t sect,
+ void *addr, unsigned long len)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline int blk_panic_flush(struct block_device *bdev)
+{
+ return -EOPNOTSUPP;
+}
+
+#endif /* CONFIG_BLK_DEV_PANIC_WRITE */
+
struct block_device_operations {
int (*open) (struct block_device *, fmode_t);
int (*release) (struct gendisk *, fmode_t);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 4f440b3..73470af 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -195,6 +195,9 @@ struct gendisk {
#ifdef CONFIG_BLK_DEV_INTEGRITY
struct blk_integrity *integrity;
#endif
+#ifdef CONFIG_BLK_DEV_PANIC_WRITE
+ const struct panic_write_operations *pwops;
+#endif
int node_id;
};
--
1.7.9.5
next prev parent reply other threads:[~2012-11-08 13:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-08 13:05 [PATCH v2 00/26] pstore, mmc: add mmc as backend for pstore dragos.tatulea
2012-11-08 13:05 ` [PATCH v2 01/26] pstore: allow for big files dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 02/26] pstore: add flags dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 03/26] pstore: add flush dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 04/26] blkoops: add a block device oops / panic logger dragos.tatulea
2012-11-08 13:06 ` dragos.tatulea [this message]
2012-11-08 13:06 ` [PATCH v2 06/26] mmc: block: add panic write support dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 07/26] mmc: panic write: bypass host claiming dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 08/26] mmc: panic write: bypass request completion dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 09/26] mmc: panic write: suppress host not claimed warnings dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 10/26] mmc: panic write: do not msleep dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 11/26] mmc: panic write: bypass clock gating dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 12/26] mmc: panic write: bypass regulators dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 13/26] mmc: panic write: trap non panic tasks dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 14/26] mmc: panic write: bypass bus ref locking dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 15/26] mmc: sdhci: panic write: bypass spin lock dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 16/26] mmc: sdhci: panic write: no sleeping dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 17/26] mmc: sdhci: panic write: call tasklets inline dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 18/26] mmc: sdhci: panic write: no timeout timer dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 19/26] mmc: sdhci: panic write: no runtime pm dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 20/26] mmc: sdhci: panic write: no tuning dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 21/26] mmc: sdhci: panic write: poll interrupts dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 22/26] mmc: sdhci: panic write: no dma mapping dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 23/26] mmc: sdhci: panic write: resume suspended host dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 24/26] mmc: sdhci: panic write: abort request in progress dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 25/26] mmc: sdhci: panic write: trap nonpanic tasks dragos.tatulea
2012-11-08 13:06 ` [PATCH v2 26/26] mmc: sdhci-pci: add panic write support dragos.tatulea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352379984-18381-6-git-send-email-dragos.tatulea@intel.com \
--to=dragos.tatulea@intel.com \
--cc=adrian.hunter@intel.com \
--cc=cjb@laptop.org \
--cc=dragos.tatulea@gmail.com \
--cc=irina.tirdea@intel.com \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®