Commit 1eb5fa84 authored by Mike Snitzer's avatar Mike Snitzer

dm: allow targets to return output from messages they are sent

Could be useful for a target to return stats or other information.
If a target does DMEMIT() anything to @result from its .message method
then it must return 1 to the caller.
Signed-off-By: default avatarMike Snitzer <snitzer@redhat.com>
parent da5dadb4
...@@ -3387,7 +3387,8 @@ static int process_invalidate_cblocks_message(struct cache *cache, unsigned coun ...@@ -3387,7 +3387,8 @@ static int process_invalidate_cblocks_message(struct cache *cache, unsigned coun
* *
* The key migration_threshold is supported by the cache target core. * The key migration_threshold is supported by the cache target core.
*/ */
static int cache_message(struct dm_target *ti, unsigned argc, char **argv) static int cache_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
struct cache *cache = ti->private; struct cache *cache = ti->private;
......
...@@ -2942,7 +2942,8 @@ static void crypt_resume(struct dm_target *ti) ...@@ -2942,7 +2942,8 @@ static void crypt_resume(struct dm_target *ti)
* key set <key> * key set <key>
* key wipe * key wipe
*/ */
static int crypt_message(struct dm_target *ti, unsigned argc, char **argv) static int crypt_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
struct crypt_config *cc = ti->private; struct crypt_config *cc = ti->private;
int key_size, ret = -EINVAL; int key_size, ret = -EINVAL;
......
...@@ -1635,7 +1635,8 @@ static void era_status(struct dm_target *ti, status_type_t type, ...@@ -1635,7 +1635,8 @@ static void era_status(struct dm_target *ti, status_type_t type,
DMEMIT("Error"); DMEMIT("Error");
} }
static int era_message(struct dm_target *ti, unsigned argc, char **argv) static int era_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
struct era *era = ti->private; struct era *era = ti->private;
......
...@@ -1595,7 +1595,7 @@ static int target_message(struct file *filp, struct dm_ioctl *param, size_t para ...@@ -1595,7 +1595,7 @@ static int target_message(struct file *filp, struct dm_ioctl *param, size_t para
DMWARN("Target message sector outside device."); DMWARN("Target message sector outside device.");
r = -EINVAL; r = -EINVAL;
} else if (ti->type->message) } else if (ti->type->message)
r = ti->type->message(ti, argc, argv); r = ti->type->message(ti, argc, argv, result, maxlen);
else { else {
DMWARN("Target type does not support messages"); DMWARN("Target type does not support messages");
r = -EINVAL; r = -EINVAL;
......
...@@ -887,7 +887,8 @@ static int log_writes_iterate_devices(struct dm_target *ti, ...@@ -887,7 +887,8 @@ static int log_writes_iterate_devices(struct dm_target *ti,
* Messages supported: * Messages supported:
* mark <mark data> - specify the marked data. * mark <mark data> - specify the marked data.
*/ */
static int log_writes_message(struct dm_target *ti, unsigned argc, char **argv) static int log_writes_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
int r = -EINVAL; int r = -EINVAL;
struct log_writes_c *lc = ti->private; struct log_writes_c *lc = ti->private;
......
...@@ -1811,7 +1811,8 @@ static void multipath_status(struct dm_target *ti, status_type_t type, ...@@ -1811,7 +1811,8 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
spin_unlock_irqrestore(&m->lock, flags); spin_unlock_irqrestore(&m->lock, flags);
} }
static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) static int multipath_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
int r = -EINVAL; int r = -EINVAL;
struct dm_dev *dev; struct dm_dev *dev;
......
...@@ -3663,7 +3663,8 @@ static void raid_status(struct dm_target *ti, status_type_t type, ...@@ -3663,7 +3663,8 @@ static void raid_status(struct dm_target *ti, status_type_t type,
} }
} }
static int raid_message(struct dm_target *ti, unsigned int argc, char **argv) static int raid_message(struct dm_target *ti, unsigned int argc, char **argv,
char *result, unsigned maxlen)
{ {
struct raid_set *rs = ti->private; struct raid_set *rs = ti->private;
struct mddev *mddev = &rs->md; struct mddev *mddev = &rs->md;
......
...@@ -466,7 +466,8 @@ static int process_set_region_mappings(struct switch_ctx *sctx, ...@@ -466,7 +466,8 @@ static int process_set_region_mappings(struct switch_ctx *sctx,
* *
* Only set_region_mappings is supported. * Only set_region_mappings is supported.
*/ */
static int switch_message(struct dm_target *ti, unsigned argc, char **argv) static int switch_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
static DEFINE_MUTEX(message_mutex); static DEFINE_MUTEX(message_mutex);
......
...@@ -3705,7 +3705,8 @@ static int process_release_metadata_snap_mesg(unsigned argc, char **argv, struct ...@@ -3705,7 +3705,8 @@ static int process_release_metadata_snap_mesg(unsigned argc, char **argv, struct
* reserve_metadata_snap * reserve_metadata_snap
* release_metadata_snap * release_metadata_snap
*/ */
static int pool_message(struct dm_target *ti, unsigned argc, char **argv) static int pool_message(struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen)
{ {
int r = -EINVAL; int r = -EINVAL;
struct pool_c *pt = ti->private; struct pool_c *pt = ti->private;
......
...@@ -87,7 +87,8 @@ typedef void (*dm_resume_fn) (struct dm_target *ti); ...@@ -87,7 +87,8 @@ typedef void (*dm_resume_fn) (struct dm_target *ti);
typedef void (*dm_status_fn) (struct dm_target *ti, status_type_t status_type, typedef void (*dm_status_fn) (struct dm_target *ti, status_type_t status_type,
unsigned status_flags, char *result, unsigned maxlen); unsigned status_flags, char *result, unsigned maxlen);
typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv); typedef int (*dm_message_fn) (struct dm_target *ti, unsigned argc, char **argv,
char *result, unsigned maxlen);
typedef int (*dm_prepare_ioctl_fn) (struct dm_target *ti, typedef int (*dm_prepare_ioctl_fn) (struct dm_target *ti,
struct block_device **bdev, fmode_t *mode); struct block_device **bdev, fmode_t *mode);
......
...@@ -270,9 +270,9 @@ enum { ...@@ -270,9 +270,9 @@ enum {
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
#define DM_VERSION_MAJOR 4 #define DM_VERSION_MAJOR 4
#define DM_VERSION_MINOR 37 #define DM_VERSION_MINOR 38
#define DM_VERSION_PATCHLEVEL 0 #define DM_VERSION_PATCHLEVEL 0
#define DM_VERSION_EXTRA "-ioctl (2017-09-20)" #define DM_VERSION_EXTRA "-ioctl (2018-02-28)"
/* Status bits */ /* Status bits */
#define DM_READONLY_FLAG (1 << 0) /* In/Out */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment