Simplify the print format string with new '%pD'
Subsystems (15)
cover Simplify the print format string with new '%pD'
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(-)
Signature · 1 line
2.17.1
RFC PATCH 1/13 s390/hmcdrv: remove the redundant directory path in format string
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.
--- drivers/s390/char/hmcdrv_dev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/s390/char/hmcdrv_dev.c +5 -5
@@ -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; }
Signature · 1 line
2.17.1
RFC PATCH 2/13 afs: Remove the number postfix of '%pD' in format string
In reply to Jia HeAfter the behavior of '%pD' is changed to print the full path of file, the previous number postfix of '%p' is pointless.
--- fs/afs/mntpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/mntpt.c +1 -1
@@ -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 ; }
Signature · 1 line
2.17.1
RFC PATCH 3/13 fs: Remove the number postfix of '%pD' in format string
In reply to Jia HeAfter the behavior of '%pD' is changed to print the full path of file, the previous number postfix of '%pD' is pointless.
--- fs/exec.c | 2 +- fs/ioctl.c | 2 +- fs/read_write.c | 2 +- fs/splice.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
fs/exec.c +1 -1
@@ -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); }
fs/ioctl.c +1 -1
@@ -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); }
fs/read_write.c +1 -1
@@ -422,7 +422,7 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lostatic 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 ; }
fs/splice.c +1 -1
@@ -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 ; }
Signature · 1 line
2.17.1
RFC PATCH 4/13 NFS: Remove the number postfix of '%pD' in format string
In reply to Jia HeAfter the behavior of '%pD' is changed to print the full path of file, the previous number postfix is pointless.
--- 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(-)
fs/nfs/dir.c +6 -6
@@ -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 ;
fs/nfs/direct.c +2 -2
@@ -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);
fs/nfs/file.c +13 -13
@@ -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 ))
fs/nfs/nfs4file.c +1 -1
@@ -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 )
fs/nfs/write.c +1 -1
@@ -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)
Signature · 1 line
2.17.1
RFC PATCH 5/13 NFSD: Remove the number postfix of '%pD' in format string
In reply to Jia HeAfter the behavior of '%pD' is changed to print the full path of file, the previous number postfix is pointless.
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -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)
Signature · 1 line
2.17.1
RFC PATCH 6/13 ovl: remove the number postfix of '%pD' in format string
In reply to Jia HeAfter the behavior of '%pD' is changed to print the full path of file, the previous number postfix is pointless.
--- fs/overlayfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/file.c +1 -1
@@ -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);
Signature · 1 line
2.17.1
RFC PATCH 7/13 iomap: simplify iomap_swapfile_fail() with '%pD' specifier
In reply to Jia HeAfter 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.
--- fs/iomap/direct-io.c | 2 +- fs/iomap/swapfile.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-)
fs/iomap/direct-io.c +1 -1
@@ -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 :
fs/iomap/swapfile.c +1 -7
@@ -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 ; }
Signature · 1 line
2.17.1
Re: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
Quoted 9 lines · Jia He
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(), thekmalloc()is not required any more.Besides, the previous number postfix of '%pD' in format string is pointless.
Quoted 7 lines
Cc Christoph Hellwig <[email protected]>Cc "Darrick J. Wong" <[email protected]>Suggested-by Christoph Hellwig <[email protected]>Signed-off-by Jia He <[email protected]>
Seems reasonable to me...
--D
Quoted 40 lines
--- fs/iomap/direct-io.c | 2 +- fs/iomap/swapfile.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-)fs/iomap/direct-io.c +1
-1@@ -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 :fs/iomap/swapfile.c +1
-7@@ -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 ; }Signature · 1 line
2.17.1
Re: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
In reply to Jia HeQuoted 8 lines · Jia He
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(), thekmalloc()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.
RE: [PATCH RFC 07/13] iomap: simplify iomap_swapfile_fail() with '%pD' specifier
Hi Christoph
Quoted 15 lines
-----Original Message-----
From: Christoph Hellwig <[email protected]>
Sent: Friday, July 16, 2021 2:11 PM
To: Justin He <[email protected]>
Cc: [email protected]; Linus Torvalds <torvalds@linux- foundation.org>; Christoph Hellwig <[email protected]>; nd <[email protected]>; Darrick J. Wong <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH RFC 07/13] iomap: simplifyiomap_swapfile_fail()with '%pD' specifierQuoted 3 lines · Jia He
After the behavior of '%pD' is change to print the full path of file,
iomap_swapfile_fail()can be simplified.
Quoted 8 lines
Quoted 5 lines
Given the space with proper length would be allocated in
vprintk_store(), thekmalloc()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 mentionsiomap_swapfile_fail.
Okay, I will refine the msg in next version.
Thanks
--
Cheers,
Justin (Jia He)
RFC PATCH 8/13 fs/coredump: simplify the printing with '%pD' and '%pd' specifier
In reply to Jia HeAfter 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.
--- fs/coredump.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
fs/coredump.c +4 -22
@@ -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; }
Signature · 1 line
2.17.1
RFC PATCH 9/13 mm/filemap: simplify the printing with '%pD' specifier
In reply to Jia HeAfter 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().
--- mm/filemap.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
mm/filemap.c +1 -6
@@ -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); } }
Signature · 1 line
2.17.1
RFC PATCH 10/13 usb: gadget: simplify the printing with '%pD' specifier
In reply to Jia HeAfter 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().
--- drivers/usb/gadget/function/f_mass_storage.c | 28 ++++++++------------ 1 file changed, 11 insertions(+), 17 deletions(-)
drivers/usb/gadget/function/f_mass_storage.c +11 -17
@@ -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 ;
Signature · 1 line
2.17.1
Re: [PATCH RFC 10/13] usb: gadget: simplify the printing with '%pD' specifier
Quoted 9 lines · Jia He
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 ind_path_unsafe(), the error string would be copied in '%pD' buffer, no need to additionally handleIS_ERR().
Quoted 7 lines
Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc "Gustavo A. R. Silva" <[email protected]>Cc Chen Lin <[email protected]>Signed-off-by Jia He <[email protected]>
Signature · 1 line
balbi
Re: [PATCH RFC 10/13] usb: gadget: simplify the printing with '%pD' specifier
In reply to Jia HeQuoted 16 lines · Jia He
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 ind_path_unsafe(), the error string would be copied in '%pD' buffer, no need to additionally handleIS_ERR().Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc "Gustavo A. R. Silva" <[email protected]>Cc Chen Lin <[email protected]>Signed-off-by Jia He <[email protected]>
Quoted 3 lines
--- drivers/usb/gadget/function/f_mass_storage.c | 28 ++++++++------------ 1 file changed, 11 insertions(+), 17 deletions(-)
RFC PATCH 11/13 md/bitmap: simplify the printing with '%pD' specifier
In reply to Jia HeAfter 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().
--- drivers/md/md-bitmap.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/md/md-bitmap.c +2 -11
@@ -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));
Signature · 1 line
2.17.1
Re: [PATCH RFC 11/13] md/bitmap: simplify the printing with '%pD' specifier
Quoted 35 lines · Jia He
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 ind_path_unsafe(), the error string would be copied in '%pD' buffer, no need to additionally handleIS_ERR().Cc Song Liu <[email protected]>Signed-off-by Jia He <[email protected]>--- drivers/md/md-bitmap.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)drivers/md/md-bitmap.c +0
-6@@ -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 );
drivers/md/md-bitmap.c static void md_bitmap_file_unmap(struct bitmap_storage *store) · line 873
Quoted 10 lines
drivers/md/md-bitmap.c +2
-5- -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 <[email protected]>
Thanks,
Guoqing
Re: [PATCH RFC 11/13] md/bitmap: simplify the printing with '%pD' specifier
Quoted 34 lines · Guoqing Jiang
Quoted 30 lines · Jia He
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 ind_path_unsafe(), the error string would be copied in '%pD' buffer, no need to additionally handleIS_ERR().Cc Song Liu <[email protected]>Signed-off-by Jia He <[email protected]>--- drivers/md/md-bitmap.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)drivers/md/md-bitmap.c +0
-2@@ -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);
Quoted 12 lines
drivers/md/md-bitmap.c static void md_bitmap_file_unmap(struct bitmap_storage *store) · line 870
Quoted 12 lines
drivers/md/md-bitmap.c +2
-9if (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!
Quoted 5 lines
drivers/md/md-bitmap.c static void md_bitmap_file_unmap(struct bitmap_storage *store) · line 873
Quoted 3 lines
drivers/md/md-bitmap.c +0
-0}else pr_warn ("%s: disabling internal bitmap due to errors\n" ,bmname (bitmap));Looks good, Acked-by: Guoqing Jiang <[email protected]>
RFC PATCH 12/13 mm: simplify the printing with '%pd' specifier
In reply to Jia HeUse '%pd' to simplify the printing since kbasename(file_path()) is to get the last dentry of the full path.
--- mm/memory.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
mm/memory.c +6 -10
@@ -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); }
Signature · 1 line
2.17.1
RFC PATCH 13/13 ext4: simplify the printing with '%pD' specifier
In reply to Jia HeAfter 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().
--- fs/ext4/super.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
fs/ext4/super.c +4 -8
@@ -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,
Signature · 1 line
2.17.1