All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 00/13] Simplify the print format string with new '%pD'
@ 2021-07-15  3:15 Jia He
  2021-07-15  3:15 ` [PATCH RFC 01/13] s390/hmcdrv: remove the redundant directory path in format string Jia He
                   ` (12 more replies)
  0 siblings, 13 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He

This is the followup work after changing the behavior of '%pD' to
print the full path of file.

Background
==========
Linus suggested printing the full path of file instead of printing
the components as '%pd'.

This series is based on my patch series of making '%pD' print the full
path of file [1], which is stable now.

[1]: https://lkml.org/lkml/2021/7/14/1519

Test
====
I only tested it with basic compilation and booting. All the changed
codes are compiled and built successfully on Arm64. Therefore set it as
RFC.

Patch details
=============
Patches 01 to 06 with minor changes are easy for review. They are to
remove the hard coding and the postfix number of previous '%pD'. This
should be removed after the '%pD' behavior is changed.

Patches 07 to 13 are changed to simplify the printing helpers.

Jia He (13):
  s390/hmcdrv: remove the redundant directory path in format string
  afs: Remove the number postfix of '%pD' in format string
  fs: Remove the number postfix of '%pD' in format string
  NFS: Remove the number postfix of '%pD' in format string
  NFSD: Remove the number postfix of '%pD' in format string
  ovl: remove the number postfix of '%pD' in format string
  iomap: simplify iomap_swapfile_fail() with '%pD' specifier
  fs/coredump: simplify the printing with '%pD' and '%pd' specifier
  mm/filemap: simplify the printing with '%pD' specifier
  usb: gadget: simplify the printing with '%pD' specifier
  md/bitmap: simplify the printing with '%pD' specifier
  mm: simplify the printing with '%pd' specifier
  ext4: simplify the printing with '%pD' specifier

 drivers/md/md-bitmap.c                       | 13 ++-------
 drivers/s390/char/hmcdrv_dev.c               | 10 +++----
 drivers/usb/gadget/function/f_mass_storage.c | 28 ++++++++------------
 fs/afs/mntpt.c                               |  2 +-
 fs/coredump.c                                | 26 +++---------------
 fs/exec.c                                    |  2 +-
 fs/ext4/super.c                              | 12 +++------
 fs/ioctl.c                                   |  2 +-
 fs/iomap/direct-io.c                         |  2 +-
 fs/iomap/swapfile.c                          |  8 +-----
 fs/nfs/dir.c                                 | 12 ++++-----
 fs/nfs/direct.c                              |  4 +--
 fs/nfs/file.c                                | 26 +++++++++---------
 fs/nfs/nfs4file.c                            |  2 +-
 fs/nfs/write.c                               |  2 +-
 fs/nfsd/nfs4state.c                          |  2 +-
 fs/overlayfs/file.c                          |  2 +-
 fs/read_write.c                              |  2 +-
 fs/splice.c                                  |  2 +-
 mm/filemap.c                                 |  7 +----
 mm/memory.c                                  | 16 +++++------
 21 files changed, 65 insertions(+), 117 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH RFC 01/13] s390/hmcdrv: remove the redundant directory path in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 02/13] afs: Remove the number postfix of '%pD' " Jia He
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger, linux-s390

After the behavior of '%pD' is changed to print the full path of file,
it would be better to use '%pD' instead of hard coding the parent
mountpoint.

Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: linux-s390@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 drivers/s390/char/hmcdrv_dev.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/s390/char/hmcdrv_dev.c b/drivers/s390/char/hmcdrv_dev.c
index 20e9cd542e03..cdde75508c8a 100644
--- a/drivers/s390/char/hmcdrv_dev.c
+++ b/drivers/s390/char/hmcdrv_dev.c
@@ -137,7 +137,7 @@ static int hmcdrv_dev_open(struct inode *inode, struct file *fp)
 	if (rc)
 		module_put(THIS_MODULE);
 
-	pr_debug("open file '/dev/%pD' with return code %d\n", fp, rc);
+	pr_debug("open file '%pD' with return code %d\n", fp, rc);
 	return rc;
 }
 
@@ -146,7 +146,7 @@ static int hmcdrv_dev_open(struct inode *inode, struct file *fp)
  */
 static int hmcdrv_dev_release(struct inode *inode, struct file *fp)
 {
-	pr_debug("closing file '/dev/%pD'\n", fp);
+	pr_debug("closing file '%pD'\n", fp);
 	kfree(fp->private_data);
 	fp->private_data = NULL;
 	hmcdrv_ftp_shutdown();
@@ -231,7 +231,7 @@ static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
 	retlen = hmcdrv_dev_transfer((char *) fp->private_data,
 				     *pos, ubuf, len);
 
-	pr_debug("read from file '/dev/%pD' at %lld returns %zd/%zu\n",
+	pr_debug("read from file '%pD' at %lld returns %zd/%zu\n",
 		 fp, (long long) *pos, retlen, len);
 
 	if (retlen > 0)
@@ -248,7 +248,7 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
 {
 	ssize_t retlen;
 
-	pr_debug("writing file '/dev/%pD' at pos. %lld with length %zd\n",
+	pr_debug("writing file '%pD' at pos. %lld with length %zd\n",
 		 fp, (long long) *pos, len);
 
 	if (!fp->private_data) { /* first expect a cmd write */
@@ -272,7 +272,7 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
 	if (retlen > 0)
 		*pos += retlen;
 
-	pr_debug("write to file '/dev/%pD' returned %zd\n", fp, retlen);
+	pr_debug("write to file '%pD' returned %zd\n", fp, retlen);
 
 	return retlen;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 02/13] afs: Remove the number postfix of '%pD' in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
  2021-07-15  3:15 ` [PATCH RFC 01/13] s390/hmcdrv: remove the redundant directory path in format string Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 03/13] fs: " Jia He
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, David Howells,
	Marc Dionne, linux-afs

After the behavior of '%pD' is changed to print the full path of file,
the previous number postfix of '%p' is pointless.

Cc: David Howells <dhowells@redhat.com>
Cc: Marc Dionne <marc.dionne@auristor.com>
Cc: linux-afs@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/afs/mntpt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index bbb2c210d139..e55233bde20f 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -61,7 +61,7 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
  */
 static int afs_mntpt_open(struct inode *inode, struct file *file)
 {
-	_enter("%p,%p{%pD2}", inode, file, file);
+	_enter("%p,%p{%pD}", inode, file, file);
 	return -EREMOTE;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 03/13] fs: Remove the number postfix of '%pD' in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
  2021-07-15  3:15 ` [PATCH RFC 01/13] s390/hmcdrv: remove the redundant directory path in format string Jia He
  2021-07-15  3:15 ` [PATCH RFC 02/13] afs: Remove the number postfix of '%pD' " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 04/13] NFS: " Jia He
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Alexander Viro,
	linux-fsdevel

After the behavior of '%pD' is changed to print the full path of file,
the previous number postfix of '%pD' is pointless.

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/exec.c       | 2 +-
 fs/ioctl.c      | 2 +-
 fs/read_write.c | 2 +-
 fs/splice.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 38f63451b928..a9f9de7da8ff 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -811,7 +811,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	BUG_ON(prev != vma);
 
 	if (unlikely(vm_flags & VM_EXEC)) {
-		pr_warn_once("process '%pD4' started with executable stack\n",
+		pr_warn_once("process '%pD' started with executable stack\n",
 			     bprm->file);
 	}
 
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 1e2204fa9963..80c9d3d00c8f 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -78,7 +78,7 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
 
 	if (block > INT_MAX) {
 		error = -ERANGE;
-		pr_warn_ratelimited("[%s/%d] FS: %s File: %pD4 would truncate fibmap result\n",
+		pr_warn_ratelimited("[%s/%d] FS: %s File: %pD would truncate fibmap result\n",
 				    current->comm, task_pid_nr(current),
 				    sb->s_id, filp);
 	}
diff --git a/fs/read_write.c b/fs/read_write.c
index 9db7adf160d2..3fdb17e4b712 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -422,7 +422,7 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
 static int warn_unsupported(struct file *file, const char *op)
 {
 	pr_warn_ratelimited(
-		"kernel %s not supported for file %pD4 (pid: %d comm: %.20s)\n",
+		"kernel %s not supported for file %pD (pid: %d comm: %.20s)\n",
 		op, file, current->pid, current->comm);
 	return -EINVAL;
 }
diff --git a/fs/splice.c b/fs/splice.c
index 5dbce4dcc1a7..4b0b9029b5ca 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -751,7 +751,7 @@ EXPORT_SYMBOL(generic_splice_sendpage);
 static int warn_unsupported(struct file *file, const char *op)
 {
 	pr_debug_ratelimited(
-		"splice %s not supported for file %pD4 (pid: %d comm: %.20s)\n",
+		"splice %s not supported for file %pD (pid: %d comm: %.20s)\n",
 		op, file, current->pid, current->comm);
 	return -EINVAL;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 04/13] NFS: Remove the number postfix of '%pD' in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (2 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 03/13] fs: " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 05/13] NFSD: " Jia He
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Trond Myklebust,
	Anna Schumaker, linux-nfs

After the behavior of '%pD' is changed to print the full path of file,
the previous number postfix is pointless.

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/nfs/dir.c      | 12 ++++++------
 fs/nfs/direct.c   |  4 ++--
 fs/nfs/file.c     | 26 +++++++++++++-------------
 fs/nfs/nfs4file.c |  2 +-
 fs/nfs/write.c    |  2 +-
 5 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1a6d2867fba4..77e210bf42aa 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -108,7 +108,7 @@ nfs_opendir(struct inode *inode, struct file *filp)
 	int res = 0;
 	struct nfs_open_dir_context *ctx;
 
-	dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
+	dfprintk(FILE, "NFS: open dir(%pD)\n", filp);
 
 	nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 
@@ -453,7 +453,7 @@ static int nfs_readdir_search_for_cookie(struct nfs_cache_array *array,
 				if (desc->duped > 0
 				    && desc->dup_cookie == desc->dir_cookie) {
 					if (printk_ratelimit()) {
-						pr_notice("NFS: directory %pD2 contains a readdir loop."
+						pr_notice("NFS: directory %pD contains a readdir loop."
 								"Please contact your server vendor.  "
 								"The file: %s has duplicate cookie %llu\n",
 								desc->file, array->array[i].name, desc->dir_cookie);
@@ -1081,7 +1081,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
 	struct nfs_readdir_descriptor *desc;
 	int res;
 
-	dfprintk(FILE, "NFS: readdir(%pD2) starting at cookie %llu\n",
+	dfprintk(FILE, "NFS: readdir(%pD) starting at cookie %llu\n",
 			file, (long long)ctx->pos);
 	nfs_inc_stats(inode, NFSIOS_VFSGETDENTS);
 
@@ -1155,7 +1155,7 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx)
 	kfree(desc);
 
 out:
-	dfprintk(FILE, "NFS: readdir(%pD2) returns %d\n", file, res);
+	dfprintk(FILE, "NFS: readdir(%pD) returns %d\n", file, res);
 	return res;
 }
 
@@ -1163,7 +1163,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
 {
 	struct nfs_open_dir_context *dir_ctx = filp->private_data;
 
-	dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n",
+	dfprintk(FILE, "NFS: llseek dir(%pD, %lld, %d)\n",
 			filp, offset, whence);
 
 	switch (whence) {
@@ -1205,7 +1205,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
 static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end,
 			 int datasync)
 {
-	dfprintk(FILE, "NFS: fsync dir(%pD2) datasync %d\n", filp, datasync);
+	dfprintk(FILE, "NFS: fsync dir(%pD) datasync %d\n", filp, datasync);
 
 	nfs_inc_stats(file_inode(filp), NFSIOS_VFSFSYNC);
 	return 0;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 2e894fec036b..762675a837a5 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -450,7 +450,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter)
 	size_t count = iov_iter_count(iter);
 	nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count);
 
-	dfprintk(FILE, "NFS: direct read(%pD2, %zd@%Ld)\n",
+	dfprintk(FILE, "NFS: direct read(%pD, %zd@%Ld)\n",
 		file, count, (long long) iocb->ki_pos);
 
 	result = 0;
@@ -902,7 +902,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
 	struct nfs_lock_context *l_ctx;
 	loff_t pos, end;
 
-	dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
+	dfprintk(FILE, "NFS: direct write(%pD, %zd@%Ld)\n",
 		file, iov_iter_count(iter), (long long) iocb->ki_pos);
 
 	result = generic_write_checks(iocb, iter);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 1fef107961bc..fbdec0e0dcce 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -66,7 +66,7 @@ nfs_file_open(struct inode *inode, struct file *filp)
 {
 	int res;
 
-	dprintk("NFS: open file(%pD2)\n", filp);
+	dprintk("NFS: open file(%pD)\n", filp);
 
 	nfs_inc_stats(inode, NFSIOS_VFSOPEN);
 	res = nfs_check_flags(filp->f_flags);
@@ -80,7 +80,7 @@ nfs_file_open(struct inode *inode, struct file *filp)
 int
 nfs_file_release(struct inode *inode, struct file *filp)
 {
-	dprintk("NFS: release(%pD2)\n", filp);
+	dprintk("NFS: release(%pD)\n", filp);
 
 	nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
 	nfs_file_clear_open_context(filp);
@@ -114,7 +114,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
 
 loff_t nfs_file_llseek(struct file *filp, loff_t offset, int whence)
 {
-	dprintk("NFS: llseek file(%pD2, %lld, %d)\n",
+	dprintk("NFS: llseek file(%pD, %lld, %d)\n",
 			filp, offset, whence);
 
 	/*
@@ -142,7 +142,7 @@ nfs_file_flush(struct file *file, fl_owner_t id)
 	struct inode	*inode = file_inode(file);
 	errseq_t since;
 
-	dprintk("NFS: flush(%pD2)\n", file);
+	dprintk("NFS: flush(%pD)\n", file);
 
 	nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
 	if ((file->f_mode & FMODE_WRITE) == 0)
@@ -163,7 +163,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 	if (iocb->ki_flags & IOCB_DIRECT)
 		return nfs_file_direct_read(iocb, to);
 
-	dprintk("NFS: read(%pD2, %zu@%lu)\n",
+	dprintk("NFS: read(%pD, %zu@%lu)\n",
 		iocb->ki_filp,
 		iov_iter_count(to), (unsigned long) iocb->ki_pos);
 
@@ -185,7 +185,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
 	struct inode *inode = file_inode(file);
 	int	status;
 
-	dprintk("NFS: mmap(%pD2)\n", file);
+	dprintk("NFS: mmap(%pD)\n", file);
 
 	/* Note: generic_file_mmap() returns ENOSYS on nommu systems
 	 *       so we call that before revalidating the mapping
@@ -210,7 +210,7 @@ nfs_file_fsync_commit(struct file *file, int datasync)
 	struct inode *inode = file_inode(file);
 	int ret;
 
-	dprintk("NFS: fsync file(%pD2) datasync %d\n", file, datasync);
+	dprintk("NFS: fsync file(%pD) datasync %d\n", file, datasync);
 
 	nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
 	ret = nfs_commit_inode(inode, FLUSH_SYNC);
@@ -325,7 +325,7 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping,
 	struct page *page;
 	int once_thru = 0;
 
-	dfprintk(PAGECACHE, "NFS: write_begin(%pD2(%lu), %u@%lld)\n",
+	dfprintk(PAGECACHE, "NFS: write_begin(%pD(%lu), %u@%lld)\n",
 		file, mapping->host->i_ino, len, (long long) pos);
 
 start:
@@ -357,7 +357,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
 	struct nfs_open_context *ctx = nfs_file_open_context(file);
 	int status;
 
-	dfprintk(PAGECACHE, "NFS: write_end(%pD2(%lu), %u@%lld)\n",
+	dfprintk(PAGECACHE, "NFS: write_end(%pD(%lu), %u@%lld)\n",
 		file, mapping->host->i_ino, len, (long long) pos);
 
 	/*
@@ -548,7 +548,7 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	struct address_space *mapping;
 
-	dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD2(%lu), offset %lld)\n",
+	dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%pD(%lu), offset %lld)\n",
 		filp, filp->f_mapping->host->i_ino,
 		(long long)page_offset(page));
 
@@ -618,7 +618,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 	if (iocb->ki_flags & IOCB_DIRECT)
 		return nfs_file_direct_write(iocb, from);
 
-	dprintk("NFS: write(%pD2, %zu@%Ld)\n",
+	dprintk("NFS: write(%pD, %zu@%Ld)\n",
 		file, iov_iter_count(from), (long long) iocb->ki_pos);
 
 	if (IS_SWAPFILE(inode))
@@ -800,7 +800,7 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
 	int ret = -ENOLCK;
 	int is_local = 0;
 
-	dprintk("NFS: lock(%pD2, t=%x, fl=%x, r=%lld:%lld)\n",
+	dprintk("NFS: lock(%pD, t=%x, fl=%x, r=%lld:%lld)\n",
 			filp, fl->fl_type, fl->fl_flags,
 			(long long)fl->fl_start, (long long)fl->fl_end);
 
@@ -838,7 +838,7 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl)
 	struct inode *inode = filp->f_mapping->host;
 	int is_local = 0;
 
-	dprintk("NFS: flock(%pD2, t=%x, fl=%x)\n",
+	dprintk("NFS: flock(%pD, t=%x, fl=%x)\n",
 			filp, fl->fl_type, fl->fl_flags);
 
 	if (!(fl->fl_flags & FL_FLOCK))
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index c820de58a661..c06257b23027 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -113,7 +113,7 @@ nfs4_file_flush(struct file *file, fl_owner_t id)
 	struct inode	*inode = file_inode(file);
 	errseq_t since;
 
-	dprintk("NFS: flush(%pD2)\n", file);
+	dprintk("NFS: flush(%pD)\n", file);
 
 	nfs_inc_stats(inode, NFSIOS_VFSFLUSH);
 	if ((file->f_mode & FMODE_WRITE) == 0)
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index eae9bf114041..c75b43e2bba9 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1368,7 +1368,7 @@ int nfs_updatepage(struct file *file, struct page *page,
 
 	nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
 
-	dprintk("NFS:       nfs_updatepage(%pD2 %d@%lld)\n",
+	dprintk("NFS:       nfs_updatepage(%pD %d@%lld)\n",
 		file, count, (long long)(page_file_offset(page) + offset));
 
 	if (!count)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 05/13] NFSD: Remove the number postfix of '%pD' in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (3 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 04/13] NFS: " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 06/13] ovl: remove " Jia He
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, J. Bruce Fields,
	Chuck Lever, linux-nfs

After the behavior of '%pD' is changed to print the full path of file,
the previous number postfix is pointless.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: linux-nfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/nfsd/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index fa67ecd5fe63..e8734cde3f7b 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2456,7 +2456,7 @@ static void states_stop(struct seq_file *s, void *v)
 
 static void nfs4_show_fname(struct seq_file *s, struct nfsd_file *f)
 {
-         seq_printf(s, "filename: \"%pD2\"", f->nf_file);
+	seq_printf(s, "filename: \"%pD\"", f->nf_file);
 }
 
 static void nfs4_show_superblock(struct seq_file *s, struct nfsd_file *f)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 06/13] ovl: remove the number postfix of '%pD' in format string
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (4 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 05/13] NFSD: " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier Jia He
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Miklos Szeredi,
	linux-unionfs

After the behavior of '%pD' is changed to print the full path of file,
the previous number postfix is pointless.

Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/overlayfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 4d53d3b7e5fe..f073c32319cd 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -62,7 +62,7 @@ static struct file *ovl_open_realfile(const struct file *file,
 	}
 	revert_creds(old_cred);
 
-	pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n",
+	pr_debug("open(%p[%pD/%c], 0%o) -> (%p, 0%o)\n",
 		 file, file, ovl_whatisit(inode, realinode), file->f_flags,
 		 realfile, IS_ERR(realfile) ? 0 : realfile->f_flags);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (5 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 06/13] ovl: remove " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15 17:11   ` Darrick J. Wong
  2021-07-16  6:11   ` Christoph Hellwig
  2021-07-15  3:15 ` [PATCH RFC 08/13] fs/coredump: simplify the printing with '%pD' and '%pd' specifier Jia He
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Darrick J. Wong,
	linux-xfs, linux-fsdevel

After the behavior of '%pD' is change to print the full path of file,
iomap_swapfile_fail() can be simplified.

Given the space with proper length would be allocated in vprintk_store(),
the kmalloc() is not required any more.

Besides, the previous number postfix of '%pD' in format string is
pointless.

Cc: Christoph Hellwig <hch@infradead.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/iomap/direct-io.c | 2 +-
 fs/iomap/swapfile.c  | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 9398b8c31323..e876a5f9d888 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -426,7 +426,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 		 * iomap_apply() call in the DIO path, then it will see the
 		 * DELALLOC block that the page-mkwrite allocated.
 		 */
-		pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD4 Comm: %.20s\n",
+		pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD Comm: %.20s\n",
 				    dio->iocb->ki_filp, current->comm);
 		return -EIO;
 	default:
diff --git a/fs/iomap/swapfile.c b/fs/iomap/swapfile.c
index 6250ca6a1f85..17032c14e466 100644
--- a/fs/iomap/swapfile.c
+++ b/fs/iomap/swapfile.c
@@ -73,13 +73,7 @@ static int iomap_swapfile_add_extent(struct iomap_swapfile_info *isi)
 
 static int iomap_swapfile_fail(struct iomap_swapfile_info *isi, const char *str)
 {
-	char *buf, *p = ERR_PTR(-ENOMEM);
-
-	buf = kmalloc(PATH_MAX, GFP_KERNEL);
-	if (buf)
-		p = file_path(isi->file, buf, PATH_MAX);
-	pr_err("swapon: file %s %s\n", IS_ERR(p) ? "<unknown>" : p, str);
-	kfree(buf);
+	pr_err("swapon: file %pD %s\n", isi->file, str);
 	return -EINVAL;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 08/13] fs/coredump: simplify the printing with '%pD' and '%pd' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (6 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 09/13] mm/filemap: simplify the printing with '%pD' specifier Jia He
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Alexander Viro,
	linux-fsdevel

After the behavior of '%pD' is changed to print the full path of file,
the printing of dentry and struct file name can be simplified.

Given the space with proper length would be allocated in vprintk_store(),
it is worthy of dropping kmalloc()/kfree() to avoid additional space
allocation.

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/coredump.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 07afb5ddb1c4..88063056a801 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -156,35 +156,17 @@ int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
 static int cn_print_exe_file(struct core_name *cn, bool name_only)
 {
 	struct file *exe_file;
-	char *pathbuf, *path, *ptr;
 	int ret;
 
 	exe_file = get_mm_exe_file(current->mm);
 	if (!exe_file)
 		return cn_esc_printf(cn, "%s (path unknown)", current->comm);
 
-	pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
-	if (!pathbuf) {
-		ret = -ENOMEM;
-		goto put_exe_file;
-	}
-
-	path = file_path(exe_file, pathbuf, PATH_MAX);
-	if (IS_ERR(path)) {
-		ret = PTR_ERR(path);
-		goto free_buf;
-	}
-
-	if (name_only) {
-		ptr = strrchr(path, '/');
-		if (ptr)
-			path = ptr + 1;
-	}
-	ret = cn_esc_printf(cn, "%s", path);
+	if (name_only)
+		ret = cn_esc_printf(cn, "%pd", exe_file->f_path.dentry);
+	else
+		ret = cn_esc_printf(cn, "%pD", exe_file);
 
-free_buf:
-	kfree(pathbuf);
-put_exe_file:
 	fput(exe_file);
 	return ret;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 09/13] mm/filemap: simplify the printing with '%pD' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (7 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 08/13] fs/coredump: simplify the printing with '%pD' and '%pd' specifier Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 10/13] usb: gadget: " Jia He
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Andrew Morton, linux-mm

After the behavior of '%pD' is changed to print the full path of file,
the log printing in dio_warn_stale_pagecache() can be simplified.

Given that the error case is well handled in d_path_unsafe(), the error
string would be copied in '%pD' buffer, no need to additionally handle
IS_ERR().

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 mm/filemap.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index d1458ecf2f51..477288017765 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3497,16 +3497,11 @@ EXPORT_SYMBOL(pagecache_write_end);
 void dio_warn_stale_pagecache(struct file *filp)
 {
 	static DEFINE_RATELIMIT_STATE(_rs, 86400 * HZ, DEFAULT_RATELIMIT_BURST);
-	char pathname[128];
-	char *path;
 
 	errseq_set(&filp->f_mapping->wb_err, -EIO);
 	if (__ratelimit(&_rs)) {
-		path = file_path(filp, pathname, sizeof(pathname));
-		if (IS_ERR(path))
-			path = "(unknown)";
 		pr_crit("Page cache invalidation failure on direct I/O.  Possible data corruption due to collision with buffered I/O!\n");
-		pr_crit("File: %s PID: %d Comm: %.20s\n", path, current->pid,
+		pr_crit("File: %pD PID: %d Comm: %.20s\n", filp, current->pid,
 			current->comm);
 	}
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 10/13] usb: gadget: simplify the printing with '%pD' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (8 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 09/13] mm/filemap: simplify the printing with '%pD' specifier Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  7:26   ` Felipe Balbi
  2021-07-15  8:10   ` Greg Kroah-Hartman
  2021-07-15  3:15 ` [PATCH RFC 11/13] md/bitmap: " Jia He
                   ` (2 subsequent siblings)
  12 siblings, 2 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Felipe Balbi,
	Greg Kroah-Hartman, Gustavo A. R. Silva, Chen Lin, linux-usb

After the behavior of '%pD' is changed to print the full path of file,
the log printing in fsg_common_create_lun() can be simplified.

Given the space with proper length would be allocated in vprintk_store(),
it is worthy of dropping kmalloc()/kfree() to avoid additional space
allocation. The error case is well handled in d_path_unsafe(), the error
string would be copied in '%pD' buffer, no need to additionally handle
IS_ERR().

Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Chen Lin <chen.lin5@zte.com.cn>
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 drivers/usb/gadget/function/f_mass_storage.c | 28 ++++++++------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 4a4703634a2a..04d4e8a0f6fd 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2738,7 +2738,6 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
 			  const char **name_pfx)
 {
 	struct fsg_lun *lun;
-	char *pathbuf, *p;
 	int rc = -ENOMEM;
 
 	if (id >= ARRAY_SIZE(common->luns))
@@ -2790,22 +2789,17 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
 			goto error_lun;
 	}
 
-	pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
-	p = "(no medium)";
-	if (fsg_lun_is_open(lun)) {
-		p = "(error)";
-		if (pathbuf) {
-			p = file_path(lun->filp, pathbuf, PATH_MAX);
-			if (IS_ERR(p))
-				p = "(error)";
-		}
-	}
-	pr_info("LUN: %s%s%sfile: %s\n",
-	      lun->removable ? "removable " : "",
-	      lun->ro ? "read only " : "",
-	      lun->cdrom ? "CD-ROM " : "",
-	      p);
-	kfree(pathbuf);
+	if (fsg_lun_is_open(lun))
+		pr_info("LUN: %s%s%sfile: %pD\n",
+			lun->removable ? "removable " : "",
+			lun->ro ? "read only " : "",
+			lun->cdrom ? "CD-ROM " : "",
+			lun->filp);
+	else
+		pr_info("LUN: %s%s%sfile: (no medium)\n",
+			lun->removable ? "removable " : "",
+			lun->ro ? "read only " : "",
+			lun->cdrom ? "CD-ROM " : "");
 
 	return 0;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 11/13] md/bitmap: simplify the printing with '%pD' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (9 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 10/13] usb: gadget: " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-16  9:38   ` Guoqing Jiang
  2021-07-15  3:15 ` [PATCH RFC 12/13] mm: simplify the printing with '%pd' specifier Jia He
  2021-07-15  3:15 ` [PATCH RFC 13/13] ext4: simplify the printing with '%pD' specifier Jia He
  12 siblings, 1 reply; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Song Liu, linux-raid

After the behavior of '%pD' is changed to print the full path of file,
the log printing can be simplified.

Given the space with proper length would be allocated in vprintk_store(),
it is worthy of dropping kmalloc()/kfree() to avoid additional space
allocation. The error case is well handled in d_path_unsafe(), the error
string would be copied in '%pD' buffer, no need to additionally handle
IS_ERR().

Cc: Song Liu <song@kernel.org>
Cc: linux-raid@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 drivers/md/md-bitmap.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index e29c6298ef5c..a82f1c2ef83c 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -862,21 +862,12 @@ static void md_bitmap_file_unmap(struct bitmap_storage *store)
  */
 static void md_bitmap_file_kick(struct bitmap *bitmap)
 {
-	char *path, *ptr = NULL;
-
 	if (!test_and_set_bit(BITMAP_STALE, &bitmap->flags)) {
 		md_bitmap_update_sb(bitmap);
 
 		if (bitmap->storage.file) {
-			path = kmalloc(PAGE_SIZE, GFP_KERNEL);
-			if (path)
-				ptr = file_path(bitmap->storage.file,
-					     path, PAGE_SIZE);
-
-			pr_warn("%s: kicking failed bitmap file %s from array!\n",
-				bmname(bitmap), IS_ERR(ptr) ? "" : ptr);
-
-			kfree(path);
+			pr_warn("%s: kicking failed bitmap file %pD from array!\n",
+				bmname(bitmap), bitmap->storage.file);
 		} else
 			pr_warn("%s: disabling internal bitmap due to errors\n",
 				bmname(bitmap));
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 12/13] mm: simplify the printing with '%pd' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (10 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 11/13] md/bitmap: " Jia He
@ 2021-07-15  3:15 ` Jia He
  2021-07-15  3:15 ` [PATCH RFC 13/13] ext4: simplify the printing with '%pD' specifier Jia He
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Andrew Morton, linux-mm

Use '%pd' to simplify the printing since kbasename(file_path()) is to
get the last dentry of the full path.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 mm/memory.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/mm/memory.c b/mm/memory.c
index 747a01d495f2..350692ada6f7 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5217,18 +5217,14 @@ void print_vma_addr(char *prefix, unsigned long ip)
 	vma = find_vma(mm, ip);
 	if (vma && vma->vm_file) {
 		struct file *f = vma->vm_file;
-		char *buf = (char *)__get_free_page(GFP_NOWAIT);
-		if (buf) {
-			char *p;
-
-			p = file_path(f, buf, PAGE_SIZE);
-			if (IS_ERR(p))
-				p = "?";
-			printk("%s%s[%lx+%lx]", prefix, kbasename(p),
+
+		if (f)
+			printk("%s%pd[%lx+%lx]", prefix, f->f_path.dentry,
 					vma->vm_start,
 					vma->vm_end - vma->vm_start);
-			free_page((unsigned long)buf);
-		}
+		else
+			printk("%s?[%lx+%lx]", prefix, vma->vm_start,
+					vma->vm_end - vma->vm_start);
 	}
 	mmap_read_unlock(mm);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH RFC 13/13] ext4: simplify the printing with '%pD' specifier
  2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
                   ` (11 preceding siblings ...)
  2021-07-15  3:15 ` [PATCH RFC 12/13] mm: simplify the printing with '%pd' specifier Jia He
@ 2021-07-15  3:15 ` Jia He
  12 siblings, 0 replies; 21+ messages in thread
From: Jia He @ 2021-07-15  3:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He, Theodore Ts'o,
	Andreas Dilger, linux-ext4

After the behavior of '%pD' is changed to print the full path of file,
the log printing can be simplified.

The error case is well handled in d_path_unsafe(), the error string
would be copied in '%pD' buffer, no need to additionally handle IS_ERR().

Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jia He <justin.he@arm.com>
---
 fs/ext4/super.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index dfa09a277b56..89ad5a334b80 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -803,31 +803,27 @@ void __ext4_error_file(struct file *file, const char *function,
 	va_list args;
 	struct va_format vaf;
 	struct inode *inode = file_inode(file);
-	char pathname[80], *path;
 
 	if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
 		return;
 
 	trace_ext4_error(inode->i_sb, function, line);
 	if (ext4_error_ratelimit(inode->i_sb)) {
-		path = file_path(file, pathname, sizeof(pathname));
-		if (IS_ERR(path))
-			path = "(unknown)";
 		va_start(args, fmt);
 		vaf.fmt = fmt;
 		vaf.va = &args;
 		if (block)
 			printk(KERN_CRIT
 			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
-			       "block %llu: comm %s: path %s: %pV\n",
+			       "block %llu: comm %s: path %pD: %pV\n",
 			       inode->i_sb->s_id, function, line, inode->i_ino,
-			       block, current->comm, path, &vaf);
+			       block, current->comm, file, &vaf);
 		else
 			printk(KERN_CRIT
 			       "EXT4-fs error (device %s): %s:%d: inode #%lu: "
-			       "comm %s: path %s: %pV\n",
+			       "comm %s: path %pD: %pV\n",
 			       inode->i_sb->s_id, function, line, inode->i_ino,
-			       current->comm, path, &vaf);
+			       current->comm, file, &vaf);
 		va_end(args);
 	}
 	ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 10/13] usb: gadget: simplify the printing with '%pD' specifier
  2021-07-15  3:15 ` [PATCH RFC 10/13] usb: gadget: " Jia He
@ 2021-07-15  7:26   ` Felipe Balbi
  2021-07-15  8:10   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 21+ messages in thread
From: Felipe Balbi @ 2021-07-15  7:26 UTC (permalink / raw)
  To: Jia He, linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Jia He,
	Greg Kroah-Hartman, Gustavo A. R. Silva, Chen Lin, linux-usb

[-- Attachment #1: Type: text/plain, Size: 855 bytes --]

Jia He <justin.he@arm.com> writes:

> After the behavior of '%pD' is changed to print the full path of file,
> the log printing in fsg_common_create_lun() can be simplified.
>
> Given the space with proper length would be allocated in vprintk_store(),
> it is worthy of dropping kmalloc()/kfree() to avoid additional space
> allocation. The error case is well handled in d_path_unsafe(), the error
> string would be copied in '%pD' buffer, no need to additionally handle
> IS_ERR().
>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Chen Lin <chen.lin5@zte.com.cn>
> Cc: linux-usb@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Jia He <justin.he@arm.com>

Acked-by: Felipe Balbi <balbi@kernel.org>

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 10/13] usb: gadget: simplify the printing with '%pD' specifier
  2021-07-15  3:15 ` [PATCH RFC 10/13] usb: gadget: " Jia He
  2021-07-15  7:26   ` Felipe Balbi
@ 2021-07-15  8:10   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 21+ messages in thread
From: Greg Kroah-Hartman @ 2021-07-15  8:10 UTC (permalink / raw)
  To: Jia He
  Cc: linux-kernel, Linus Torvalds, Christoph Hellwig, nd,
	Felipe Balbi, Gustavo A. R. Silva, Chen Lin, linux-usb

On Thu, Jul 15, 2021 at 11:15:30AM +0800, Jia He wrote:
> After the behavior of '%pD' is changed to print the full path of file,
> the log printing in fsg_common_create_lun() can be simplified.
> 
> Given the space with proper length would be allocated in vprintk_store(),
> it is worthy of dropping kmalloc()/kfree() to avoid additional space
> allocation. The error case is well handled in d_path_unsafe(), the error
> string would be copied in '%pD' buffer, no need to additionally handle
> IS_ERR().
> 
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Chen Lin <chen.lin5@zte.com.cn>
> Cc: linux-usb@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Jia He <justin.he@arm.com>
> ---
>  drivers/usb/gadget/function/f_mass_storage.c | 28 ++++++++------------
>  1 file changed, 11 insertions(+), 17 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
  2021-07-15  3:15 ` [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier Jia He
@ 2021-07-15 17:11   ` Darrick J. Wong
  2021-07-16  6:11   ` Christoph Hellwig
  1 sibling, 0 replies; 21+ messages in thread
From: Darrick J. Wong @ 2021-07-15 17:11 UTC (permalink / raw)
  To: Jia He
  Cc: linux-kernel, Linus Torvalds, Christoph Hellwig, nd, linux-xfs,
	linux-fsdevel

On Thu, Jul 15, 2021 at 11:15:27AM +0800, Jia He wrote:
> After the behavior of '%pD' is change to print the full path of file,
> iomap_swapfile_fail() can be simplified.
> 
> Given the space with proper length would be allocated in vprintk_store(),
> the kmalloc() is not required any more.
> 
> Besides, the previous number postfix of '%pD' in format string is
> pointless.
> 
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: "Darrick J. Wong" <djwong@kernel.org>
> Cc: linux-xfs@vger.kernel.org
> Cc: linux-fsdevel@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Suggested-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Jia He <justin.he@arm.com>

Seems reasonable to me...
Acked-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/iomap/direct-io.c | 2 +-
>  fs/iomap/swapfile.c  | 8 +-------
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 9398b8c31323..e876a5f9d888 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -426,7 +426,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
>  		 * iomap_apply() call in the DIO path, then it will see the
>  		 * DELALLOC block that the page-mkwrite allocated.
>  		 */
> -		pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD4 Comm: %.20s\n",
> +		pr_warn_ratelimited("Direct I/O collision with buffered writes! File: %pD Comm: %.20s\n",
>  				    dio->iocb->ki_filp, current->comm);
>  		return -EIO;
>  	default:
> diff --git a/fs/iomap/swapfile.c b/fs/iomap/swapfile.c
> index 6250ca6a1f85..17032c14e466 100644
> --- a/fs/iomap/swapfile.c
> +++ b/fs/iomap/swapfile.c
> @@ -73,13 +73,7 @@ static int iomap_swapfile_add_extent(struct iomap_swapfile_info *isi)
>  
>  static int iomap_swapfile_fail(struct iomap_swapfile_info *isi, const char *str)
>  {
> -	char *buf, *p = ERR_PTR(-ENOMEM);
> -
> -	buf = kmalloc(PATH_MAX, GFP_KERNEL);
> -	if (buf)
> -		p = file_path(isi->file, buf, PATH_MAX);
> -	pr_err("swapon: file %s %s\n", IS_ERR(p) ? "<unknown>" : p, str);
> -	kfree(buf);
> +	pr_err("swapon: file %pD %s\n", isi->file, str);
>  	return -EINVAL;
>  }
>  
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
  2021-07-15  3:15 ` [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier Jia He
  2021-07-15 17:11   ` Darrick J. Wong
@ 2021-07-16  6:11   ` Christoph Hellwig
  2021-07-16  6:17     ` Justin He
  1 sibling, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-07-16  6:11 UTC (permalink / raw)
  To: Jia He
  Cc: linux-kernel, Linus Torvalds, Christoph Hellwig, nd,
	Darrick J. Wong, linux-xfs, linux-fsdevel

On Thu, Jul 15, 2021 at 11:15:27AM +0800, Jia He wrote:
> After the behavior of '%pD' is change to print the full path of file,
> iomap_swapfile_fail() can be simplified.
> 
> Given the space with proper length would be allocated in vprintk_store(),
> the kmalloc() is not required any more.
> 
> Besides, the previous number postfix of '%pD' in format string is
> pointless.

This also touched iomap_dio_actor, but the commit og only mentions
iomap_swapfile_fail.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
  2021-07-16  6:11   ` Christoph Hellwig
@ 2021-07-16  6:17     ` Justin He
  0 siblings, 0 replies; 21+ messages in thread
From: Justin He @ 2021-07-16  6:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-kernel, Linus Torvalds, nd, Darrick J. Wong, linux-xfs,
	linux-fsdevel

Hi Christoph

> -----Original Message-----
> From: Christoph Hellwig <hch@infradead.org>
> Sent: Friday, July 16, 2021 2:11 PM
> To: Justin He <Justin.He@arm.com>
> Cc: linux-kernel@vger.kernel.org; Linus Torvalds <torvalds@linux-
> foundation.org>; Christoph Hellwig <hch@infradead.org>; nd <nd@arm.com>;
> Darrick J. Wong <djwong@kernel.org>; linux-xfs@vger.kernel.org; linux-
> fsdevel@vger.kernel.org
> Subject: Re: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with
> '%pD' specifier
> 
> On Thu, Jul 15, 2021 at 11:15:27AM +0800, Jia He wrote:
> > After the behavior of '%pD' is change to print the full path of file,
> > iomap_swapfile_fail() can be simplified.
> >
> > Given the space with proper length would be allocated in vprintk_store(),
> > the kmalloc() is not required any more.
> >
> > Besides, the previous number postfix of '%pD' in format string is
> > pointless.
> 
> This also touched iomap_dio_actor, but the commit og only mentions
> iomap_swapfile_fail.
Okay, I will refine the msg in next version.
Thanks


--
Cheers,
Justin (Jia He)



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 11/13] md/bitmap: simplify the printing with '%pD' specifier
  2021-07-15  3:15 ` [PATCH RFC 11/13] md/bitmap: " Jia He
@ 2021-07-16  9:38   ` Guoqing Jiang
  2021-07-23 17:05     ` Song Liu
  0 siblings, 1 reply; 21+ messages in thread
From: Guoqing Jiang @ 2021-07-16  9:38 UTC (permalink / raw)
  To: Jia He, linux-kernel
  Cc: Linus Torvalds, Christoph Hellwig, nd, Song Liu, linux-raid



On 7/15/21 11:15 AM, Jia He wrote:
> After the behavior of '%pD' is changed to print the full path of file,
> the log printing can be simplified.
>
> Given the space with proper length would be allocated in vprintk_store(),
> it is worthy of dropping kmalloc()/kfree() to avoid additional space
> allocation. The error case is well handled in d_path_unsafe(), the error
> string would be copied in '%pD' buffer, no need to additionally handle
> IS_ERR().
>
> Cc: Song Liu <song@kernel.org>
> Cc: linux-raid@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Jia He <justin.he@arm.com>
> ---
>   drivers/md/md-bitmap.c | 13 ++-----------
>   1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index e29c6298ef5c..a82f1c2ef83c 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -862,21 +862,12 @@ static void md_bitmap_file_unmap(struct bitmap_storage *store)
>    */
>   static void md_bitmap_file_kick(struct bitmap *bitmap)
>   {
> -	char *path, *ptr = NULL;
> -
>   	if (!test_and_set_bit(BITMAP_STALE, &bitmap->flags)) {
>   		md_bitmap_update_sb(bitmap);
>   
>   		if (bitmap->storage.file) {
> -			path = kmalloc(PAGE_SIZE, GFP_KERNEL);
> -			if (path)
> -				ptr = file_path(bitmap->storage.file,
> -					     path, PAGE_SIZE);
> -
> -			pr_warn("%s: kicking failed bitmap file %s from array!\n",
> -				bmname(bitmap), IS_ERR(ptr) ? "" : ptr);
> -
> -			kfree(path);
> +			pr_warn("%s: kicking failed bitmap file %pD from array!\n",
> +				bmname(bitmap), bitmap->storage.file);
>   		} else
>   			pr_warn("%s: disabling internal bitmap due to errors\n",
>   				bmname(bitmap));

Looks good,  Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Thanks,
Guoqing

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH RFC 11/13] md/bitmap: simplify the printing with '%pD' specifier
  2021-07-16  9:38   ` Guoqing Jiang
@ 2021-07-23 17:05     ` Song Liu
  0 siblings, 0 replies; 21+ messages in thread
From: Song Liu @ 2021-07-23 17:05 UTC (permalink / raw)
  To: Guoqing Jiang
  Cc: Jia He, open list, Linus Torvalds, Christoph Hellwig, nd, linux-raid

On Fri, Jul 16, 2021 at 2:41 AM Guoqing Jiang <guoqing.jiang@linux.dev> wrote:
>
>
>
> On 7/15/21 11:15 AM, Jia He wrote:
> > After the behavior of '%pD' is changed to print the full path of file,
> > the log printing can be simplified.
> >
> > Given the space with proper length would be allocated in vprintk_store(),
> > it is worthy of dropping kmalloc()/kfree() to avoid additional space
> > allocation. The error case is well handled in d_path_unsafe(), the error
> > string would be copied in '%pD' buffer, no need to additionally handle
> > IS_ERR().
> >
> > Cc: Song Liu <song@kernel.org>
> > Cc: linux-raid@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Jia He <justin.he@arm.com>
> > ---
> >   drivers/md/md-bitmap.c | 13 ++-----------
> >   1 file changed, 2 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> > index e29c6298ef5c..a82f1c2ef83c 100644
> > --- a/drivers/md/md-bitmap.c
> > +++ b/drivers/md/md-bitmap.c
> > @@ -862,21 +862,12 @@ static void md_bitmap_file_unmap(struct bitmap_storage *store)
> >    */
> >   static void md_bitmap_file_kick(struct bitmap *bitmap)
> >   {
> > -     char *path, *ptr = NULL;
> > -
> >       if (!test_and_set_bit(BITMAP_STALE, &bitmap->flags)) {
> >               md_bitmap_update_sb(bitmap);
> >
> >               if (bitmap->storage.file) {
> > -                     path = kmalloc(PAGE_SIZE, GFP_KERNEL);
> > -                     if (path)
> > -                             ptr = file_path(bitmap->storage.file,
> > -                                          path, PAGE_SIZE);
> > -
> > -                     pr_warn("%s: kicking failed bitmap file %s from array!\n",
> > -                             bmname(bitmap), IS_ERR(ptr) ? "" : ptr);
> > -
> > -                     kfree(path);
> > +                     pr_warn("%s: kicking failed bitmap file %pD from array!\n",
> > +                             bmname(bitmap), bitmap->storage.file);

This is neat!

Acked-by: Song Liu <song@kernel.org>




> >               } else
> >                       pr_warn("%s: disabling internal bitmap due to errors\n",
> >                               bmname(bitmap));
>
> Looks good,  Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-07-23 17:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15  3:15 [PATCH RFC 00/13] Simplify the print format string with new '%pD' Jia He
2021-07-15  3:15 ` [PATCH RFC 01/13] s390/hmcdrv: remove the redundant directory path in format string Jia He
2021-07-15  3:15 ` [PATCH RFC 02/13] afs: Remove the number postfix of '%pD' " Jia He
2021-07-15  3:15 ` [PATCH RFC 03/13] fs: " Jia He
2021-07-15  3:15 ` [PATCH RFC 04/13] NFS: " Jia He
2021-07-15  3:15 ` [PATCH RFC 05/13] NFSD: " Jia He
2021-07-15  3:15 ` [PATCH RFC 06/13] ovl: remove " Jia He
2021-07-15  3:15 ` [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier Jia He
2021-07-15 17:11   ` Darrick J. Wong
2021-07-16  6:11   ` Christoph Hellwig
2021-07-16  6:17     ` Justin He
2021-07-15  3:15 ` [PATCH RFC 08/13] fs/coredump: simplify the printing with '%pD' and '%pd' specifier Jia He
2021-07-15  3:15 ` [PATCH RFC 09/13] mm/filemap: simplify the printing with '%pD' specifier Jia He
2021-07-15  3:15 ` [PATCH RFC 10/13] usb: gadget: " Jia He
2021-07-15  7:26   ` Felipe Balbi
2021-07-15  8:10   ` Greg Kroah-Hartman
2021-07-15  3:15 ` [PATCH RFC 11/13] md/bitmap: " Jia He
2021-07-16  9:38   ` Guoqing Jiang
2021-07-23 17:05     ` Song Liu
2021-07-15  3:15 ` [PATCH RFC 12/13] mm: simplify the printing with '%pd' specifier Jia He
2021-07-15  3:15 ` [PATCH RFC 13/13] ext4: simplify the printing with '%pD' specifier Jia He

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.