nvme: move namespace scanning to core
[linux-2.6-block.git] / drivers / nvme / host / nvme.h
index 41e922b33f11993fb4bbb2b711feadf3ea831c16..9b63e719318ac5c15ac3c4ce9ead8e1f3327a165 100644 (file)
@@ -67,7 +67,16 @@ enum nvme_quirks {
        NVME_QUIRK_DISCARD_ZEROES               = (1 << 2),
 };
 
+enum nvme_ctrl_state {
+       NVME_CTRL_NEW,
+       NVME_CTRL_LIVE,
+       NVME_CTRL_RESETTING,
+       NVME_CTRL_DELETING,
+};
+
 struct nvme_ctrl {
+       enum nvme_ctrl_state state;
+       spinlock_t lock;
        const struct nvme_ctrl_ops *ops;
        struct request_queue *admin_q;
        struct device *dev;
@@ -99,6 +108,7 @@ struct nvme_ctrl {
        u32 vs;
        bool subsystem;
        unsigned long quirks;
+       struct work_struct scan_work;
 };
 
 /*
@@ -138,6 +148,7 @@ struct nvme_ctrl_ops {
        int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
        int (*reset_ctrl)(struct nvme_ctrl *ctrl);
        void (*free_ctrl)(struct nvme_ctrl *ctrl);
+       void (*post_scan)(struct nvme_ctrl *ctrl);
 };
 
 static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl)
@@ -187,6 +198,8 @@ static inline bool nvme_req_needs_retry(struct request *req, u16 status)
                (jiffies - req->start_time) < req->timeout;
 }
 
+bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
+               enum nvme_ctrl_state new_state);
 int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
 int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
@@ -196,7 +209,7 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
 void nvme_put_ctrl(struct nvme_ctrl *ctrl);
 int nvme_init_identify(struct nvme_ctrl *ctrl);
 
-void nvme_scan_namespaces(struct nvme_ctrl *ctrl);
+void nvme_queue_scan(struct nvme_ctrl *ctrl);
 void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
 
 void nvme_stop_queues(struct nvme_ctrl *ctrl);