From: Mike Christie <michael.christie@oracle.com>
To: hch@infradead.org, martin.petersen@oracle.com,
james.bottomley@hansenpartnership.com,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Cc: Mike Christie <michael.christie@oracle.com>,
Christoph Hellwig <hch@lst.de>
Subject: [PATCH v2 4/5] scsi: target: Add file configure_unmap callout
Date: Tue, 28 Jun 2022 15:02:29 -0500 [thread overview]
Message-ID: <20220628200230.15052-5-michael.christie@oracle.com> (raw)
In-Reply-To: <20220628200230.15052-1-michael.christie@oracle.com>
Move file's unmap setup code to a configure_unmap callout.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
drivers/target/target_core_file.c | 33 ++++++++++++++++++-------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index e8440e5dd804..28aa643be5d5 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -86,6 +86,24 @@ static struct se_device *fd_alloc_device(struct se_hba *hba, const char *name)
return &fd_dev->dev;
}
+static bool fd_configure_unmap(struct se_device *dev)
+{
+ struct file *file = FD_DEV(dev)->fd_file;
+ struct inode *inode = file->f_mapping->host;
+
+ if (S_ISBLK(inode->i_mode))
+ return target_configure_unmap_from_queue(&dev->dev_attrib,
+ I_BDEV(inode));
+
+ /* Limit UNMAP emulation to 8k Number of LBAs (NoLB) */
+ dev->dev_attrib.max_unmap_lba_count = 0x2000;
+ /* Currently hardcoded to 1 in Linux/SCSI code. */
+ dev->dev_attrib.max_unmap_block_desc_count = 1;
+ dev->dev_attrib.unmap_granularity = 1;
+ dev->dev_attrib.unmap_granularity_alignment = 0;
+ return true;
+}
+
static int fd_configure_device(struct se_device *dev)
{
struct fd_dev *fd_dev = FD_DEV(dev);
@@ -149,10 +167,6 @@ static int fd_configure_device(struct se_device *dev)
" block_device blocks: %llu logical_block_size: %d\n",
dev_size, div_u64(dev_size, fd_dev->fd_block_size),
fd_dev->fd_block_size);
-
- if (target_configure_unmap_from_queue(&dev->dev_attrib, bdev))
- pr_debug("IFILE: BLOCK Discard support available,"
- " disabled by default\n");
/*
* Enable write same emulation for IBLOCK and use 0xFFFF as
* the smaller WRITE_SAME(10) only has a two-byte block count.
@@ -170,16 +184,6 @@ static int fd_configure_device(struct se_device *dev)
}
fd_dev->fd_block_size = FD_BLOCKSIZE;
- /*
- * Limit UNMAP emulation to 8k Number of LBAs (NoLB)
- */
- dev->dev_attrib.max_unmap_lba_count = 0x2000;
- /*
- * Currently hardcoded to 1 in Linux/SCSI code..
- */
- dev->dev_attrib.max_unmap_block_desc_count = 1;
- dev->dev_attrib.unmap_granularity = 1;
- dev->dev_attrib.unmap_granularity_alignment = 0;
/*
* Limit WRITE_SAME w/ UNMAP=0 emulation to 8k Number of LBAs (NoLB)
@@ -923,6 +927,7 @@ static const struct target_backend_ops fileio_ops = {
.configure_device = fd_configure_device,
.destroy_device = fd_destroy_device,
.free_device = fd_free_device,
+ .configure_unmap = fd_configure_unmap,
.parse_cdb = fd_parse_cdb,
.set_configfs_dev_params = fd_set_configfs_dev_params,
.show_configfs_dev_params = fd_show_configfs_dev_params,
--
2.25.1
next prev parent reply other threads:[~2022-06-28 20:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 20:02 [PATCH v2 0/5] target: UNMAP/WRITE_SAME features/cleanups for 5.20 Mike Christie
2022-06-28 20:02 ` [PATCH v2 1/5] scsi: target: Remove incorrect zero blocks WRITE_SAME check Mike Christie
2022-06-28 20:02 ` [PATCH v2 2/5] scsi: target: Add callout to configure unmap settings Mike Christie
2022-06-28 20:02 ` [PATCH v2 3/5] scsi: target: Add iblock configure_unmap callout Mike Christie
2022-06-28 20:02 ` Mike Christie [this message]
2022-06-28 20:02 ` [PATCH v2 5/5] scsi: target: Detect unmap support post configuration Mike Christie
2022-07-07 20:54 ` [PATCH v2 0/5] target: UNMAP/WRITE_SAME features/cleanups for 5.20 Martin K. Petersen
2022-07-14 4:22 ` Martin K. Petersen
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=20220628200230.15052-5-michael.christie@oracle.com \
--to=michael.christie@oracle.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).