Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Brian King <brking@us.ibm.com>, Hannes Reinecke <hare@suse.com>,
	 "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	 Matthew Wilcox <willy@infradead.org>,
	Mike Rapoport <rppt@kernel.org>,
	 Wen Xiong <wenxiong@linux.ibm.com>,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	linux-scsi@vger.kernel.org,  target-devel@vger.kernel.org,
	Hannes Reinecke <hare@kernel.org>
Subject: [PATCH v2 1/4] scsi: target: file: use kmalloc() to allocate temporary protection buffer
Date: Sat, 04 Jul 2026 09:13:34 +0300	[thread overview]
Message-ID: <20260704-b4-scsi-v2-1-7d2d21a810de@kernel.org> (raw)
In-Reply-To: <20260704-b4-scsi-v2-0-7d2d21a810de@kernel.org>

fd_do_prot_unmap() uses __get_free_page() to allocate a temporary buffer
that is used to invalidate protection info for the unmapped region by
filling with 0xff pattern.

This buffer can be allocated with kmalloc() as there's nothing special
about it to go directly to the page allocator.

kmalloc() provides a better API that does not require ugly casts and
kfree() does not need to know the size of the freed object.

Replace use of __get_free_page() with kmalloc().

Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---
 drivers/target/target_core_file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 62ced9f5102f..ab9824a4852f 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -516,7 +516,7 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
 	void *buf;
 	int rc;
 
-	buf = (void *)__get_free_page(GFP_KERNEL);
+	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!buf) {
 		pr_err("Unable to allocate FILEIO prot buf\n");
 		return -ENOMEM;
@@ -524,7 +524,7 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
 
 	rc = fd_do_prot_fill(cmd->se_dev, lba, nolb, buf, PAGE_SIZE);
 
-	free_page((unsigned long)buf);
+	kfree(buf);
 
 	return rc;
 }

-- 
2.53.0


  reply	other threads:[~2026-07-04  6:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04  6:13 [PATCH v2 0/4] scsi: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-07-04  6:13 ` Mike Rapoport (Microsoft) [this message]
2026-07-04  6:13 ` [PATCH v2 2/4] scsi: proc: use kmalloc() in proc writers Mike Rapoport (Microsoft)
2026-07-04  6:13 ` [PATCH v2 3/4] scsi: ipr: use kmalloc() to allocate IPR dump buffer memory Mike Rapoport (Microsoft)
2026-07-04  6:28   ` sashiko-bot
2026-07-04  6:13 ` [PATCH v2 4/4] scsi: sym53c8xx_2: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-07-04  6:22   ` sashiko-bot

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=20260704-b4-scsi-v2-1-7d2d21a810de@kernel.org \
    --to=rppt@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brking@us.ibm.com \
    --cc=hare@kernel.org \
    --cc=hare@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=target-devel@vger.kernel.org \
    --cc=wenxiong@linux.ibm.com \
    --cc=willy@infradead.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