linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Sergei Shtepa <sergei.shtepa@veeam.com>
Cc: axboe@kernel.dk, corbet@lwn.net, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 18/21] block, blksnap: snapshot
Date: Sun,  1 Jan 2023 19:05:42 +0800	[thread overview]
Message-ID: <20230101110542.3395-1-hdanton@sina.com> (raw)
In-Reply-To: <20221209142331.26395-19-sergei.shtepa@veeam.com>

On 9 Dec 2022 15:23:28 +0100 Sergei Shtepa <sergei.shtepa@veeam.com>
> +int snapshot_create(struct blk_snap_dev *dev_id_array, unsigned int count,
> +		    uuid_t *id)
> +{
> +	struct snapshot *snapshot = NULL;
> +	int ret;
> +	unsigned int inx;
> +
> +	pr_info("Create snapshot for devices:\n");
> +	for (inx = 0; inx < count; ++inx)
> +		pr_info("\t%u:%u\n", dev_id_array[inx].mj,
> +			dev_id_array[inx].mn);
> +
> +	ret = check_same_devices(dev_id_array, count);
> +	if (ret)
> +		return ret;
> +
> +	snapshot = snapshot_new(count);
> +	if (IS_ERR(snapshot)) {
> +		pr_err("Unable to create snapshot: failed to allocate snapshot structure\n");
> +		return PTR_ERR(snapshot);
> +	}
> +
> +	ret = -ENODEV;
> +	for (inx = 0; inx < count; ++inx) {
> +		dev_t dev_id =
> +			MKDEV(dev_id_array[inx].mj, dev_id_array[inx].mn);
> +		struct tracker *tracker;
> +
> +		tracker = tracker_create_or_get(dev_id);
> +		if (IS_ERR(tracker)) {
> +			pr_err("Unable to create snapshot\n");
> +			pr_err("Failed to add device [%u:%u] to snapshot tracking\n",
> +			       MAJOR(dev_id), MINOR(dev_id));
> +			ret = PTR_ERR(tracker);
> +			goto fail;
> +		}
> +
> +		snapshot->tracker_array[inx] = tracker;
> +		snapshot->count++;
> +	}
> +
> +	down_write(&snapshots_lock);
> +	list_add_tail(&snapshots, &snapshot->link);
> +	up_write(&snapshots_lock);

Given list_for_each_entry below, typo wrt &snapshots found in the fresh 2023?

> +
> +	uuid_copy(id, &snapshot->id);
> +	pr_info("Snapshot %pUb was created\n", &snapshot->id);
> +	return 0;
> +fail:
> +	pr_err("Snapshot cannot be created\n");
> +
> +	snapshot_put(snapshot);
> +	return ret;
> +}
> +
> +static struct snapshot *snapshot_get_by_id(uuid_t *id)
> +{
> +	struct snapshot *snapshot = NULL;
> +	struct snapshot *s;
> +
> +	down_read(&snapshots_lock);
> +	if (list_empty(&snapshots))
> +		goto out;
> +
> +	list_for_each_entry(s, &snapshots, link) {
> +		if (uuid_equal(&s->id, id)) {
> +			snapshot = s;
> +			snapshot_get(snapshot);
> +			break;
> +		}
> +	}
> +out:
> +	up_read(&snapshots_lock);
> +	return snapshot;
> +}


  parent reply	other threads:[~2023-01-01 11:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221209142331.26395-1-sergei.shtepa@veeam.com>
     [not found] ` <20221209142331.26395-18-sergei.shtepa@veeam.com>
2023-01-01  7:18   ` [PATCH v2 17/21] block, blksnap: snapshot image block device Hillf Danton
2023-01-02  9:44     ` Sergei Shtepa
     [not found] ` <20221209142331.26395-19-sergei.shtepa@veeam.com>
2023-01-01 11:05   ` Hillf Danton [this message]
2023-01-02  9:58     ` [PATCH v2 18/21] block, blksnap: snapshot Sergei Shtepa

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=20230101110542.3395-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=axboe@kernel.dk \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sergei.shtepa@veeam.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