cregit-Linux how code gets into the kernel

Release 4.14 drivers/md/dm-snap-transient.c

Directory: drivers/md
/*
 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
 * Copyright (C) 2006-2008 Red Hat GmbH
 *
 * This file is released under the GPL.
 */

#include "dm-exception-store.h"

#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/vmalloc.h>
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/dm-io.h>


#define DM_MSG_PREFIX "transient snapshot"

/*-----------------------------------------------------------------
 * Implementation of the store for non-persistent snapshots.
 *---------------------------------------------------------------*/

struct transient_c {
	
sector_t next_free;
};


static void transient_dtr(struct dm_exception_store *store) { kfree(store->context); }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon1794.44%150.00%
Jonathan E Brassow15.56%150.00%
Total18100.00%2100.00%


static int transient_read_metadata(struct dm_exception_store *store, int (*callback)(void *callback_context, chunk_t old, chunk_t new), void *callback_context) { return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jonathan E Brassow2160.00%150.00%
Alasdair G. Kergon1440.00%150.00%
Total35100.00%2100.00%


static int transient_prepare_exception(struct dm_exception_store *store, struct dm_exception *e) { struct transient_c *tc = store->context; sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev); if (size < (tc->next_free + store->chunk_size)) return -1; e->new_chunk = sector_to_chunk(store, tc->next_free); tc->next_free += store->chunk_size; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon7692.68%125.00%
Mike Snitzer44.88%125.00%
Jonathan E Brassow22.44%250.00%
Total82100.00%4100.00%


static void transient_commit_exception(struct dm_exception_store *store, struct dm_exception *e, int valid, void (*callback) (void *, int success), void *callback_context) { /* Just succeed */ callback(callback_context, valid); }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon3886.36%125.00%
Mikulas Patocka49.09%125.00%
Jonathan E Brassow24.55%250.00%
Total44100.00%4100.00%


static void transient_usage(struct dm_exception_store *store, sector_t *total_sectors, sector_t *sectors_allocated, sector_t *metadata_sectors) { *sectors_allocated = ((struct transient_c *) store->context)->next_free; *total_sectors = get_dev_size(dm_snap_cow(store->snap)->bdev); *metadata_sectors = 0; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon4169.49%133.33%
Mike Snitzer1830.51%266.67%
Total59100.00%3100.00%


static int transient_ctr(struct dm_exception_store *store, char *options) { struct transient_c *tc; tc = kmalloc(sizeof(struct transient_c), GFP_KERNEL); if (!tc) return -ENOMEM; tc->next_free = 0; store->context = tc; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon5189.47%133.33%
Jonathan E Brassow58.77%133.33%
Mike Snitzer11.75%133.33%
Total57100.00%3100.00%


static unsigned transient_status(struct dm_exception_store *store, status_type_t status, char *result, unsigned maxlen) { unsigned sz = 0; switch (status) { case STATUSTYPE_INFO: break; case STATUSTYPE_TABLE: DMEMIT(" N %llu", (unsigned long long)store->chunk_size); } return sz; }

Contributors

PersonTokensPropCommitsCommitProp
Jonathan E Brassow5598.21%266.67%
Mike Snitzer11.79%133.33%
Total56100.00%3100.00%

static struct dm_exception_store_type _transient_type = { .name = "transient", .module = THIS_MODULE, .ctr = transient_ctr, .dtr = transient_dtr, .read_metadata = transient_read_metadata, .prepare_exception = transient_prepare_exception, .commit_exception = transient_commit_exception, .usage = transient_usage, .status = transient_status, }; static struct dm_exception_store_type _transient_compat_type = { .name = "N", .module = THIS_MODULE, .ctr = transient_ctr, .dtr = transient_dtr, .read_metadata = transient_read_metadata, .prepare_exception = transient_prepare_exception, .commit_exception = transient_commit_exception, .usage = transient_usage, .status = transient_status, };
int dm_transient_snapshot_init(void) { int r; r = dm_exception_store_type_register(&_transient_type); if (r) { DMWARN("Unable to register transient exception store type"); return r; } r = dm_exception_store_type_register(&_transient_compat_type); if (r) { DMWARN("Unable to register old-style transient " "exception store type"); dm_exception_store_type_unregister(&_transient_type); return r; } return r; }

Contributors

PersonTokensPropCommitsCommitProp
Jonathan E Brassow5585.94%150.00%
Alasdair G. Kergon914.06%150.00%
Total64100.00%2100.00%


void dm_transient_snapshot_exit(void) { dm_exception_store_type_unregister(&_transient_type); dm_exception_store_type_unregister(&_transient_compat_type); }

Contributors

PersonTokensPropCommitsCommitProp
Jonathan E Brassow1473.68%150.00%
Alasdair G. Kergon526.32%150.00%
Total19100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Alasdair G. Kergon28349.39%110.00%
Jonathan E Brassow25544.50%440.00%
Mike Snitzer284.89%330.00%
Mikulas Patocka40.70%110.00%
Paul Gortmaker30.52%110.00%
Total573100.00%10100.00%
Directory: drivers/md
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.