Re: [v6,2/8] dmaengine: Add DMA_MEMCPY_SG transaction op
Hi Vinod, On 31.08.2017 12:57, Robin Murphy wrote: On 30/08/17 19:25, Dave Jiang wrote: On 08/30/2017 11:18 AM, Robin Murphy wrote: On 25/08/17 21:59, Dave Jiang wrote: Adding a dmaengine transaction operation that allows copy to/from a scatterlist and a flat buffer. Apologies if I'm late to the party, but doesn't DMA_SG already cover this use-case? As far as I can see, all this does is save the caller from setting up a single-entry scatterlist to describe the buffer - even if such a simplified interface is justified it seems like something that could be implemented as a wrapper around dmaengine_prep_dma_sg() rather than the providers having to implement a whole extra callback. DMA_SG is queued to be removed in 4.14. There is no in kernel consumer for the code. Ah, I see, that's what I was missing. So we're effectively just replacing that interface with a more pragmatic alternative - that makes sense. What are the plans with this new DMA_MEMCPY_SG interface? When will it hit mainline or is something missing? Thanks, Stefan ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC patch v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
Hi, here is my second version of nvdimm daemon, It would be appreciated if you could check it. Change log since v1: - Adding a config file(/etc/nvdimmd/nvdimmd.conf) - Using struct log_ctx instead of syslog() - Using log_syslog() to save the notify messages to syslog - Using log_file() to save the notify messages to special file - Adding LOG_NOTICE level into log_priority - Using automake instead of Makefile - Adding a new util file(nvdimmd/util.c) including helper functions needed for nvdimm daemon. - Adding nvdimmd_test program --- This is a patch set of nvdimmd, a tiny daemon to monitor the features of over threshold events. When an over thershold event fires, nvdimmd will output the notification including dimm health status to syslog or a special file to users' configuration. Users can choose the output format to be structured json or text. Here are out put samples. - json format: 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify { "dev":"nmem1", "id":"cdab-0a-07e0-feff", "handle":1, "phys_id":1, "health":{ "health_state":"non-critical", "temperature_celsius":23, "spares_percentage":75, "alarm_temperature":true, "alarm_spares":true, "temperature_threshold":40, "spares_threshold":5, "life_used_percentage":5, "shutdown_state":"clean" } } - text format: 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify dev: nmem1 health_state: non-critical spares_percentage: 75 TODO list: - The dimms to monitor should be filtered by namespace and region - Add more information into the notify message - Make nvdimmd_test an ndctl command or an option of ndctl inject-error Makefile.am | 2 +- configure.ac | 1 + nvdimmd/Makefile.am | 47 nvdimmd/libnvdimmd.c | 315 nvdimmd/libnvdimmd.h | 53 nvdimmd/nvdimmd | 228 +++ nvdimmd/nvdimmd.c | 112 + nvdimmd/nvdimmd.conf | 25 nvdimmd/nvdimmd.service | 7 ++ nvdimmd/nvdimmd_test.c | 142 ++ nvdimmd/util.c | 80 nvdimmd/util.h | 33 + util/log.c | 2 + util/log.h | 3 + 14 files changed, 1049 insertions(+), 1 deletion(-) ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH] fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
On Mon, Nov 13, 2017 at 05:27:54PM -0800, Dan Williams wrote: > While reviewing whether MAP_SYNC should strengthen its current guarantee > of syncing writes from the initiating process to also include > third-party readers observing dirty metadata, Dave pointed out that the > check of IOMAP_WRITE is misplaced. > > The policy of what to with IOMAP_F_DIRTY should be separated from the > generic filesystem mechanism of reporting dirty metadata. Move this > policy to the fs-dax core to simplify the per-filesystem iomap handlers, > and further centralize code that implements the MAP_SYNC policy. This > otherwise should not change behavior, it just makes it easier to change > behavior in the future. Yes, this was what I was looking for on my last read-through. :) > Cc: Jan Kara> Cc: Christoph Hellwig > Cc: Darrick J. Wong > Cc: Ross Zwisler > Reported-by: Dave Chinner > Signed-off-by: Dan Williams > --- > This is an additional cleanup I want to include in the 4.15 merge > request for the MAP_SYNC feature. Please review, I'm looking to send the > pull request towards the end of the week. > > > fs/dax.c | 15 +-- > fs/ext4/inode.c|2 +- > fs/xfs/xfs_iomap.c |6 +++--- > 3 files changed, 17 insertions(+), 6 deletions(-) > > diff --git a/fs/dax.c b/fs/dax.c > index 78233c716757..27ba300660ff 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1079,6 +1079,17 @@ static int dax_fault_return(int error) > return VM_FAULT_SIGBUS; > } > > +/* > + * MAP_SYNC on a dax mapping guarantees dirty metadata is > + * flushed on write-faults (non-cow), but not read-faults. > + */ > +static bool dax_fault_is_synchronous(unsigned long flags, > + struct vm_area_struct *vma, struct iomap *iomap) > +{ > + return (flags & IOMAP_WRITE) && (vma->vm_flags & VM_SYNC) > + && (iomap->flags & IOMAP_F_DIRTY); > +} > + > static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, > const struct iomap_ops *ops) > { > @@ -1170,7 +1181,7 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf, > pfn_t *pfnp, > goto finish_iomap; > } > > - sync = (vma->vm_flags & VM_SYNC) && (iomap.flags & IOMAP_F_DIRTY); > + sync = dax_fault_is_synchronous(flags, vma, ); > > switch (iomap.type) { > case IOMAP_MAPPED: > @@ -1390,7 +1401,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, > pfn_t *pfnp, > if (iomap.offset + iomap.length < pos + PMD_SIZE) > goto finish_iomap; > > - sync = (vma->vm_flags & VM_SYNC) && (iomap.flags & IOMAP_F_DIRTY); > + sync = dax_fault_is_synchronous(iomap_flags, vma, ); > > switch (iomap.type) { > case IOMAP_MAPPED: > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 13a198924a0f..ee4d907a4251 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3479,7 +3479,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t > offset, loff_t length, > } > > iomap->flags = 0; > - if ((flags & IOMAP_WRITE) && ext4_inode_datasync_dirty(inode)) > + if (ext4_inode_datasync_dirty(inode)) > iomap->flags |= IOMAP_F_DIRTY; > iomap->bdev = inode->i_sb->s_bdev; > iomap->dax_dev = sbi->s_daxdev; > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index b43be199fbdf..888b60189983 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -1087,9 +1087,9 @@ xfs_file_iomap_begin( > trace_xfs_iomap_found(ip, offset, length, 0, ); > } > > - if ((flags & IOMAP_WRITE) && xfs_ipincount(ip) && > - (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) > - iomap->flags |= IOMAP_F_DIRTY; > + if (xfs_ipincount(ip)) > + if (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP) Why not if (xfs_ipincount(ip) && (ip->... & ~XFS_ILOG_TIMESTAMP)) ? Otherwise looks ok (just this patch, will rvb the rest separately), Reviewed-by: Darrick J. Wong --D > + iomap->flags |= IOMAP_F_DIRTY; > > xfs_bmbt_to_iomap(ip, iomap, ); > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v2 1/2] ndctl: daxctl: fix mmap size
On 11/13/2017 04:40 PM, Dan Williams wrote: > On Mon, Nov 13, 2017 at 10:19 AM, Dave Jiangwrote: >> The size for mmap needs to be aligned to the region alignment. Fix the >> mapping size so that it satisfy the alignment requirement. >> >> Signed-off-by: Dave Jiang >> --- >> daxctl/io.c | 12 +++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/daxctl/io.c b/daxctl/io.c >> index 2f8cb4a..e739d0e 100644 >> --- a/daxctl/io.c >> +++ b/daxctl/io.c >> @@ -55,6 +55,7 @@ struct io_dev { >> struct ndctl_region *region; >> struct ndctl_dax *dax; >> uint64_t size; >> + uint64_t mmap_size; >> }; >> >> static struct { >> @@ -83,6 +84,7 @@ static bool is_stdinout(struct io_dev *io_dev) >> static int setup_device(struct io_dev *io_dev, size_t size) >> { >> int flags, rc; >> + unsigned long align; >> >> if (is_stdinout(io_dev)) >> return 0; >> @@ -104,8 +106,14 @@ static int setup_device(struct io_dev *io_dev, size_t >> size) >> if (!io_dev->is_dax) >> return 0; >> >> + align = ndctl_dax_get_align(io_dev->dax); >> + if (align == ULLONG_MAX) > > Isn't this always false because 'align' is 'unsigned long', not > 'unsigned long long'? > > Otherwise the rest of this looks good. > Ok I'll send out v3 if you don't have issues with the other patch. ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Delivery reports about your e-mail
The original message was received at Tue, 14 Nov 2017 11:52:38 +0800 from lists.01.org [47.11.223.161] - The following addresses had permanent fatal errors -___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v3 1/2] ndctl: daxctl: fix mmap size
On Mon, Nov 13, 2017 at 3:58 PM, Dave Jiangwrote: > The size for mmap needs to be aligned to the region alignment. Fix the > mapping size so that it satisfy the alignment requirement. > > Signed-off-by: Dave Jiang Thanks Dave, applied both. ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH v2 1/2] ndctl: daxctl: fix mmap size
On Mon, Nov 13, 2017 at 10:19 AM, Dave Jiangwrote: > The size for mmap needs to be aligned to the region alignment. Fix the > mapping size so that it satisfy the alignment requirement. > > Signed-off-by: Dave Jiang > --- > daxctl/io.c | 12 +++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/daxctl/io.c b/daxctl/io.c > index 2f8cb4a..e739d0e 100644 > --- a/daxctl/io.c > +++ b/daxctl/io.c > @@ -55,6 +55,7 @@ struct io_dev { > struct ndctl_region *region; > struct ndctl_dax *dax; > uint64_t size; > + uint64_t mmap_size; > }; > > static struct { > @@ -83,6 +84,7 @@ static bool is_stdinout(struct io_dev *io_dev) > static int setup_device(struct io_dev *io_dev, size_t size) > { > int flags, rc; > + unsigned long align; > > if (is_stdinout(io_dev)) > return 0; > @@ -104,8 +106,14 @@ static int setup_device(struct io_dev *io_dev, size_t > size) > if (!io_dev->is_dax) > return 0; > > + align = ndctl_dax_get_align(io_dev->dax); > + if (align == ULLONG_MAX) Isn't this always false because 'align' is 'unsigned long', not 'unsigned long long'? Otherwise the rest of this looks good. ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 1/2] ndctl: daxctl: fix mmap size
The size for mmap needs to be aligned to the region alignment. Fix the mapping size so that it satisfy the alignment requirement. Signed-off-by: Dave Jiang--- daxctl/io.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/daxctl/io.c b/daxctl/io.c index 2f8cb4a..6e07b52 100644 --- a/daxctl/io.c +++ b/daxctl/io.c @@ -55,6 +55,7 @@ struct io_dev { struct ndctl_region *region; struct ndctl_dax *dax; uint64_t size; + uint64_t mmap_size; }; static struct { @@ -83,6 +84,7 @@ static bool is_stdinout(struct io_dev *io_dev) static int setup_device(struct io_dev *io_dev, size_t size) { int flags, rc; + uint64_t align; if (is_stdinout(io_dev)) return 0; @@ -104,8 +106,14 @@ static int setup_device(struct io_dev *io_dev, size_t size) if (!io_dev->is_dax) return 0; + align = ndctl_dax_get_align(io_dev->dax); + if (align == ULONG_MAX) + return -ERANGE; + + io_dev->mmap_size = ALIGN(size, align); flags = (io_dev->direction == IO_READ) ? PROT_READ : PROT_WRITE; - io_dev->mmap = mmap(NULL, size, flags, MAP_SHARED, io_dev->fd, 0); + io_dev->mmap = mmap(NULL, io_dev->mmap_size, flags, + MAP_SHARED, io_dev->fd, 0); if (io_dev->mmap == MAP_FAILED) { rc = -errno; perror("mmap"); @@ -501,6 +509,8 @@ static void cleanup(void) for (i = 0; i < 2; i++) { if (is_stdinout([i])) continue; + if (io.dev[i].mmap_size) + munmap(io.dev[i].mmap, io.dev[i].mmap_size); close(io.dev[i].fd); } } ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v3 2/2] ndctl: make mmap start at the offset
Instead of mmap at the beginning of the DAX region, map at the offset that is aligned down. This reduces the mmap size we need to create. Signed-off-by: Dave Jiang--- daxctl/io.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/daxctl/io.c b/daxctl/io.c index 6e07b52..551e831 100644 --- a/daxctl/io.c +++ b/daxctl/io.c @@ -46,6 +46,7 @@ struct io_dev { const char *parm_path; char *real_path; uint64_t offset; + uint64_t offset_diff; enum io_direction direction; bool is_dax; bool is_char; @@ -84,7 +85,7 @@ static bool is_stdinout(struct io_dev *io_dev) static int setup_device(struct io_dev *io_dev, size_t size) { int flags, rc; - uint64_t align; + uint64_t align, offset; if (is_stdinout(io_dev)) return 0; @@ -112,8 +113,11 @@ static int setup_device(struct io_dev *io_dev, size_t size) io_dev->mmap_size = ALIGN(size, align); flags = (io_dev->direction == IO_READ) ? PROT_READ : PROT_WRITE; + offset = ALIGN_DOWN(io_dev->offset, align); + io_dev->offset_diff = io_dev->offset - offset; + io_dev->mmap = mmap(NULL, io_dev->mmap_size, flags, - MAP_SHARED, io_dev->fd, 0); + MAP_SHARED, io_dev->fd, offset); if (io_dev->mmap == MAP_FAILED) { rc = -errno; perror("mmap"); @@ -372,17 +376,17 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, ssize_t rc, count = 0; if (zero && dst_dev->is_dax) { - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; memset(dst, 0, len); pmem_persist(dst, len); rc = len; } else if (dst_dev->is_dax && src_dev->is_dax) { - src = (uint8_t *)src_dev->mmap + src_dev->offset; - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + src = (uint8_t *)src_dev->mmap + src_dev->offset_diff; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; pmem_memcpy_persist(dst, src, len); rc = len; } else if (src_dev->is_dax) { - src = (uint8_t *)src_dev->mmap + src_dev->offset; + src = (uint8_t *)src_dev->mmap + src_dev->offset_diff; if (dst_dev->offset) { rc = lseek(dst_dev->fd, dst_dev->offset, SEEK_SET); if (rc < 0) { @@ -407,7 +411,7 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, printf("Requested size %lu larger than source.\n", len); } else if (dst_dev->is_dax) { - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; if (src_dev->offset) { rc = lseek(src_dev->fd, src_dev->offset, SEEK_SET); if (rc < 0) { ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH] fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
While reviewing whether MAP_SYNC should strengthen its current guarantee of syncing writes from the initiating process to also include third-party readers observing dirty metadata, Dave pointed out that the check of IOMAP_WRITE is misplaced. The policy of what to with IOMAP_F_DIRTY should be separated from the generic filesystem mechanism of reporting dirty metadata. Move this policy to the fs-dax core to simplify the per-filesystem iomap handlers, and further centralize code that implements the MAP_SYNC policy. This otherwise should not change behavior, it just makes it easier to change behavior in the future. Cc: Jan KaraCc: Christoph Hellwig Cc: Darrick J. Wong Cc: Ross Zwisler Reported-by: Dave Chinner Signed-off-by: Dan Williams --- This is an additional cleanup I want to include in the 4.15 merge request for the MAP_SYNC feature. Please review, I'm looking to send the pull request towards the end of the week. fs/dax.c | 15 +-- fs/ext4/inode.c|2 +- fs/xfs/xfs_iomap.c |6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 78233c716757..27ba300660ff 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1079,6 +1079,17 @@ static int dax_fault_return(int error) return VM_FAULT_SIGBUS; } +/* + * MAP_SYNC on a dax mapping guarantees dirty metadata is + * flushed on write-faults (non-cow), but not read-faults. + */ +static bool dax_fault_is_synchronous(unsigned long flags, + struct vm_area_struct *vma, struct iomap *iomap) +{ + return (flags & IOMAP_WRITE) && (vma->vm_flags & VM_SYNC) + && (iomap->flags & IOMAP_F_DIRTY); +} + static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, const struct iomap_ops *ops) { @@ -1170,7 +1181,7 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, goto finish_iomap; } - sync = (vma->vm_flags & VM_SYNC) && (iomap.flags & IOMAP_F_DIRTY); + sync = dax_fault_is_synchronous(flags, vma, ); switch (iomap.type) { case IOMAP_MAPPED: @@ -1390,7 +1401,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, if (iomap.offset + iomap.length < pos + PMD_SIZE) goto finish_iomap; - sync = (vma->vm_flags & VM_SYNC) && (iomap.flags & IOMAP_F_DIRTY); + sync = dax_fault_is_synchronous(iomap_flags, vma, ); switch (iomap.type) { case IOMAP_MAPPED: diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 13a198924a0f..ee4d907a4251 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3479,7 +3479,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, } iomap->flags = 0; - if ((flags & IOMAP_WRITE) && ext4_inode_datasync_dirty(inode)) + if (ext4_inode_datasync_dirty(inode)) iomap->flags |= IOMAP_F_DIRTY; iomap->bdev = inode->i_sb->s_bdev; iomap->dax_dev = sbi->s_daxdev; diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index b43be199fbdf..888b60189983 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1087,9 +1087,9 @@ xfs_file_iomap_begin( trace_xfs_iomap_found(ip, offset, length, 0, ); } - if ((flags & IOMAP_WRITE) && xfs_ipincount(ip) && - (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) - iomap->flags |= IOMAP_F_DIRTY; + if (xfs_ipincount(ip)) + if (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP) + iomap->flags |= IOMAP_F_DIRTY; xfs_bmbt_to_iomap(ip, iomap, ); ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 17/18] xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()
On Wed, Nov 01, 2017 at 04:36:46PM +0100, Jan Kara wrote: > xfs_filemap_pfn_mkwrite() duplicates a lot of __xfs_filemap_fault(). > It will also need to handle flushing for synchronous page faults. So > just make that function use __xfs_filemap_fault(). > > Signed-off-by: Jan KaraLooks ok, Reviewed-by: Darrick J. Wong > --- > fs/xfs/xfs_file.c | 29 - > fs/xfs/xfs_trace.h | 2 -- > 2 files changed, 4 insertions(+), 27 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 7c6b8def6eed..4496b45678de 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -1085,37 +1085,16 @@ xfs_filemap_page_mkwrite( > } > > /* > - * pfn_mkwrite was originally inteneded to ensure we capture time stamp > - * updates on write faults. In reality, it's need to serialise against > - * truncate similar to page_mkwrite. Hence we cycle the XFS_MMAPLOCK_SHARED > - * to ensure we serialise the fault barrier in place. > + * pfn_mkwrite was originally intended to ensure we capture time stamp > updates > + * on write faults. In reality, it needs to serialise against truncate and > + * prepare memory for writing so handle is as standard write fault. > */ > static int > xfs_filemap_pfn_mkwrite( > struct vm_fault *vmf) > { > > - struct inode*inode = file_inode(vmf->vma->vm_file); > - struct xfs_inode*ip = XFS_I(inode); > - int ret = VM_FAULT_NOPAGE; > - loff_t size; > - > - trace_xfs_filemap_pfn_mkwrite(ip); > - > - sb_start_pagefault(inode->i_sb); > - file_update_time(vmf->vma->vm_file); > - > - /* check if the faulting page hasn't raced with truncate */ > - xfs_ilock(ip, XFS_MMAPLOCK_SHARED); > - size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; > - if (vmf->pgoff >= size) > - ret = VM_FAULT_SIGBUS; > - else if (IS_DAX(inode)) > - ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, _iomap_ops); > - xfs_iunlock(ip, XFS_MMAPLOCK_SHARED); > - sb_end_pagefault(inode->i_sb); > - return ret; > - > + return __xfs_filemap_fault(vmf, PE_SIZE_PTE, true); > } > > static const struct vm_operations_struct xfs_file_vm_ops = { > diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h > index bb5514688d47..6333ad09e0f3 100644 > --- a/fs/xfs/xfs_trace.h > +++ b/fs/xfs/xfs_trace.h > @@ -688,8 +688,6 @@ DEFINE_INODE_EVENT(xfs_inode_set_cowblocks_tag); > DEFINE_INODE_EVENT(xfs_inode_clear_cowblocks_tag); > DEFINE_INODE_EVENT(xfs_inode_free_cowblocks_invalid); > > -DEFINE_INODE_EVENT(xfs_filemap_pfn_mkwrite); > - > TRACE_EVENT(xfs_filemap_fault, > TP_PROTO(struct xfs_inode *ip, enum page_entry_size pe_size, >bool write_fault), > -- > 2.12.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH] fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
> - if ((flags & IOMAP_WRITE) && xfs_ipincount(ip) && > - (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) > - iomap->flags |= IOMAP_F_DIRTY; > + if (xfs_ipincount(ip)) > + if (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP) > + iomap->flags |= IOMAP_F_DIRTY; Please don't split up the conditional and make it harder to read. With that fixed up this looks fine to me: Reviewed-by: Christoph Hellwig___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 4/7] ndctl: nvdimmd: add body file of nvdimm daemon
This patch adds the body file of nvdimm daemon and compiles nvdimmd with automake. Signed-off-by: QI Fuli--- Makefile.am | 2 +- configure.ac| 1 + nvdimmd/Makefile.am | 19 + nvdimmd/nvdimmd.c | 112 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 nvdimmd/Makefile.am create mode 100644 nvdimmd/nvdimmd.c diff --git a/Makefile.am b/Makefile.am index b538b1f..ff91439 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ include Makefile.am.in ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl +SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl nvdimmd if ENABLE_DOCS SUBDIRS += Documentation/ndctl Documentation/daxctl endif diff --git a/configure.ac b/configure.ac index 5b10381..3ce71e3 100644 --- a/configure.ac +++ b/configure.ac @@ -274,6 +274,7 @@ AC_CONFIG_FILES([ daxctl/lib/Makefile ndctl/lib/Makefile ndctl/Makefile + nvdimmd/Makefile daxctl/Makefile test/Makefile Documentation/ndctl/Makefile diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am new file mode 100644 index 000..9883edd --- /dev/null +++ b/nvdimmd/Makefile.am @@ -0,0 +1,19 @@ +include $(top_srcdir)/Makefile.am.in + +bin_PROGRAMS = nvdimmd + +nvdimmd_SOURCES =\ + nvdimmd.c \ + libnvdimmd.c \ + util.c \ + ../util/log.c \ + ../util/json.c \ + ../ndctl/util/json-smart.c + +nvdimmd_LDADD = ../ndctl/lib/libndctl.la \ + ../daxctl/lib/libdaxctl.la \ + ../libutil.a \ + $(KMOD_LIBS) \ + $(JSON_LIBS) \ + $(UUID_LIBS) \ + $(UDEV_LIBS) diff --git a/nvdimmd/nvdimmd.c b/nvdimmd/nvdimmd.c new file mode 100644 index 000..f451751 --- /dev/null +++ b/nvdimmd/nvdimmd.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ + +/* + * Nvdimm daemon is used to monitor the features of over threshold events. + * It automatically searches and monitors all of the dimms which support smart + * threshold. When an over threshold event fires, it will write a notification + * into the system log. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "libnvdimmd.h" + +static int wait_threshold_notify(struct ndctl_ctx *ctx) +{ + int rc, maxfd, cnt_dimm; + struct threshold_dimm *t_dimm; + + t_dimm = calloc(NUM_MAX_DIMM, sizeof(struct threshold_dimm)); + if (!t_dimm) { + err(ctx, "t_dimm memory not allocated"); + goto out; + } + + fd_set fds; + FD_ZERO(); + + cnt_dimm = get_threshold_dimm(ctx, t_dimm, , ); + if (cnt_dimm == 0) { + err(ctx, "no dimm supports over threshold notification\n"); + goto out; + } + + rc = select(maxfd + 1, NULL, NULL, , NULL); + if (rc < 1) { + if (rc == 0) + err(ctx, "select unexpected timeout\n"); + else + err(ctx, "select %s\n", strerror(errno)); + goto out; + } + + log_notify(ctx, t_dimm, cnt_dimm, fds, rc); + + free(t_dimm); + return 0; + +out: + return 1; +} + +static void nvdimmd_log_init(struct ndctl_ctx *ctx, int priority, + const char *owner, const char *log_env) +{ + log_init(>ctx, owner, log_env); + ndctl_set_log_priority(ctx, priority); + if (strcmp(nvdimmd_cf->logfile, "syslog") == 0) + ndctl_set_log_fn(ctx, log_syslog); + else + ndctl_set_log_fn(ctx, log_file); +} + +int main(void) +{ + if (daemon(0, 0) != 0) { + syslog(LOG_ERR, "nvdimmd error: daemon start failed\n"); + exit(EXIT_FAILURE); + } + struct ndctl_ctx *ctx; + int rc, ret = 0; + const char *conf_path = "/etc/nvdimmd/nvdimmd.conf"; + + syslog(LOG_INFO, "nvdimmd: started\n"); + + if (get_nvdimmd_conf(conf_path) != 0) { + syslog(LOG_ERR, "nvdimmd.conf error \n"); + goto out; + } + + while (ret == 0) { + rc = ndctl_new(); + if (rc) + goto out; + + nvdimmd_log_init(ctx, LOG_NOTICE, "nvdimmd", "NVDIMMD_LOG"); + ret =
[RFC PATCH v2 7/7] ndctl: nvdimmd: add a temporary test for nvdimm daemon
This patch is used to test nvdimmd service temporarily. I will make it an ndctl command or an option of ndctl inject-error in next step. Currently, You can test nvdimm daemon with the following command. nvdimmd_test [nmemX] [all] Signed-off-by: QI Fuli--- nvdimmd/Makefile.am| 14 - nvdimmd/nvdimmd_test.c | 142 + 2 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 nvdimmd/nvdimmd_test.c diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am index bca0bc8..cca1980 100644 --- a/nvdimmd/Makefile.am +++ b/nvdimmd/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/Makefile.am.in -bin_PROGRAMS = nvdimmd +bin_PROGRAMS = nvdimmd nvdimmd_test nvdimmd_SOURCES =\ nvdimmd.c \ @@ -18,6 +18,18 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \ $(UUID_LIBS) \ $(UDEV_LIBS) +nvdimmd_test_SOURCES =\ + nvdimmd_test.c \ + ../util/log.c + +nvdimmd_test_LDADD =\ + ../ndctl/lib/libndctl.la \ + ../daxctl/lib/libdaxctl.la \ + ../libutil.a \ + $(KMOD_LIBS) \ + $(UUID_LIBS) \ + $(UDEV_LIBS) + unitfiles = nvdimmd.service unitdir = /usr/lib/systemd/system/ diff --git a/nvdimmd/nvdimmd_test.c b/nvdimmd/nvdimmd_test.c new file mode 100644 index 000..8d16243 --- /dev/null +++ b/nvdimmd/nvdimmd_test.c @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2017, FUJITSU LIMITED. All rirhts reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ + +/* + * This program is used to call the emulation of event of over threshold. + * You can test nvdimmd daemon with the following command. + * nvdimmd_test [nmemX] [all] + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#define NUM_MAX_DIMM 1024 +#include + +struct threshold_dimm { + struct ndctl_dimm *dimm; + const char *devname; + int health_eventfd; +}; + +const char *test_help_info = "nvdimmd_test [nmemX] [all]"; + +static int get_threshold(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm) +{ + struct ndctl_bus *bus; + struct ndctl_dimm *dimm; + int cnt_dimm = 0; + + ndctl_bus_foreach(ctx, bus) { + ndctl_dimm_foreach(bus, dimm) { + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART_THRESHOLD)) + continue; + t_dimm[cnt_dimm].dimm = dimm; + t_dimm[cnt_dimm].devname = ndctl_dimm_get_devname(dimm); + cnt_dimm++; + } + } + return cnt_dimm; +} + +static int test_submit_cmd(struct threshold_dimm *t_dimm) +{ + struct ndctl_cmd *cmd; + const char *msg = "command to call over threshold event notification: "; + + cmd = ndctl_dimm_cmd_new_smart_threshold(t_dimm->dimm); + if (!cmd) { + fprintf(stderr, "failed to prepare %s[%s]\n", + msg, t_dimm->devname); + return -1; + } + if(ndctl_cmd_submit(cmd)) { + fprintf(stderr, "failed to submit %s[%s]\n", + msg, t_dimm->devname); + return -1; + } + ndctl_cmd_unref(cmd); + return 0; +} + +static int +test_submit(struct threshold_dimm *t_dimm, int count_dimm, char *test_devname) +{ + int count_test = 0; + + for (int i= 0; i < count_dimm; i++) { + if (!strcmp(test_devname, "all")) { + if (!test_submit_cmd(_dimm[i])) + count_test++; + continue; + } + if (!strcmp(test_devname, t_dimm[i].devname)) { + if (!test_submit_cmd(_dimm[i])) + count_test++; + else + count_test--; + break; + } + } + return count_test; +} + +int main(int argc, char *argv[]) +{ + struct ndctl_ctx *ctx; + int rc, count_dimm; + char *test_devname; + struct threshold_dimm *t_dimm; + + if (argc < 1) { + fprintf(stderr, "usage: %s\n", test_help_info); + goto out; + } + + test_devname = argv[1]; + if (!test_devname || !strcmp(test_devname, "--help")){ + fprintf(stderr, "usage: %s\n", test_help_info); + goto out; + } +
[RFC PATCH v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
Hi, here is my second version of nvdimm daemon, It would be appreciated if you could check it. Change log since v1: - Adding a config file(/etc/nvdimmd/nvdimmd.conf) - Using struct log_ctx instead of syslog() - Using log_syslog() to save the notify messages to syslog - Using log_file() to save the notify messages to special file - Adding LOG_NOTICE level into log_priority - Using automake instead of Makefile - Adding a new util file(nvdimmd/util.c) including helper functions needed for nvdimm daemon. - Adding nvdimmd_test program --- This is a patch set of nvdimmd, a tiny daemon to monitor the features of over threshold events. When an over thershold event fires, nvdimmd will output the notification including dimm health status to syslog or a special file to users' configuration. Users can choose the output format to be structured json or text. Here are out put samples. - json format: 2017/11/10 11:15:03 [28065] log_notify: nvdimm dimm over threshold notify { "dev":"nmem1", "id":"cdab-0a-07e0-feff", "handle":1, "phys_id":1, "health":{ "health_state":"non-critical", "temperature_celsius":23, "spares_percentage":75, "alarm_temperature":true, "alarm_spares":true, "temperature_threshold":40, "spares_threshold":5, "life_used_percentage":5, "shutdown_state":"clean" } } - text format: 2017/11/10 16:21:53 [12479] log_notify: nvdimm dimm over threshold notify dev: nmem1 health_state: non-critical spares_percentage: 75 TODO list: - The dimms to monitor should be filtered by namespace and region - Add more information into the notify message - Make nvdimmd_test an ndctl command or an option of ndctl inject-error QI Fuli (7): ndctl: nvdimmd: add LOG_NOTICE level into log_priority ndctl: nvdimmd: add nvdimmd necessary util functions ndctl: nvdimmd: add nvdimmd necessary functions ndctl: nvdimmd: add body file of nvdimm daemon ndctl: nvdimmd: add nvdimmd config file ndctl: nvdimmd: add the unit file of systemd for nvdimmd service ndctl: nvdimmd: add a temporary test for nvdimm daemon Makefile.am | 2 +- configure.ac| 1 + nvdimmd/Makefile.am | 47 nvdimmd/libnvdimmd.c| 315 nvdimmd/libnvdimmd.h| 53 nvdimmd/nvdimmd.c | 112 + nvdimmd/nvdimmd.conf| 25 nvdimmd/nvdimmd.service | 7 ++ nvdimmd/nvdimmd_test.c | 142 ++ nvdimmd/util.c | 80 nvdimmd/util.h | 33 + util/log.c | 2 + util/log.h | 3 + 13 files changed, 821 insertions(+), 1 deletion(-) create mode 100644 nvdimmd/Makefile.am create mode 100644 nvdimmd/libnvdimmd.c create mode 100644 nvdimmd/libnvdimmd.h create mode 100644 nvdimmd/nvdimmd.c create mode 100644 nvdimmd/nvdimmd.conf create mode 100644 nvdimmd/nvdimmd.service create mode 100644 nvdimmd/nvdimmd_test.c create mode 100644 nvdimmd/util.c create mode 100644 nvdimmd/util.h -- 2.9.5 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 1/7] ndctl: nvdimmd: add LOG_NOTICE level into log_priority
This patch adds LOG_NOTICE level into log_priority for the notifications. Because the LOG_INFO level is too low for the notifications of nvdimm dimm over threshold event, and the event notifications are not up to LOG_ERROR level. Signed-off-by: QI Fuli--- util/log.c | 2 ++ util/log.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/util/log.c b/util/log.c index cc4d7d8..c60ca33 100644 --- a/util/log.c +++ b/util/log.c @@ -50,6 +50,8 @@ static int log_priority(const char *priority) return LOG_INFO; if (strncmp(priority, "debug", 5) == 0) return LOG_DEBUG; + if (strncmp(priority, "notice", 6) == 0) + return LOG_NOTICE; return 0; } diff --git a/util/log.h b/util/log.h index 5fc56e8..495e0d3 100644 --- a/util/log.h +++ b/util/log.h @@ -48,15 +48,18 @@ do { \ # endif # define log_info(ctx, arg...) log_cond(ctx, LOG_INFO, ## arg) # define log_err(ctx, arg...) log_cond(ctx, LOG_ERR, ## arg) +# define log_notice(ctx, arg...) log_cond(ctx, LOG_NOTICE, ## arg) #else # define log_dbg(ctx, arg...) log_null(ctx, ## arg) # define log_info(ctx, arg...) log_null(ctx, ## arg) # define log_err(ctx, arg...) log_null(ctx, ## arg) +# define log_notice(ctx, arg...) log_null(ctx, ## arg) #endif #define dbg(x, arg...) log_dbg(&(x)->ctx, ## arg) #define info(x, arg...) log_info(&(x)->ctx, ## arg) #define err(x, arg...) log_err(&(x)->ctx, ## arg) +#define notice(x, arg...) log_notice(&(x)->ctx, ## arg) #ifndef HAVE_SECURE_GETENV # ifdef HAVE___SECURE_GETENV -- 2.9.5 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 3/7] ndctl: nvdimmd: add nvdimmd necessary functions
Libnvdimmd is used to provide nvdimmd necessary functions. The get_nvdimmd_conf() will read the nvdimmd.conf and set the parameters' value as global variables when nvdimmd service starts. Signed-off-by: QI Fuli--- nvdimmd/libnvdimmd.c | 315 +++ nvdimmd/libnvdimmd.h | 53 + 2 files changed, 368 insertions(+) create mode 100644 nvdimmd/libnvdimmd.c create mode 100644 nvdimmd/libnvdimmd.h diff --git a/nvdimmd/libnvdimmd.c b/nvdimmd/libnvdimmd.c new file mode 100644 index 000..7e5d16b --- /dev/null +++ b/nvdimmd/libnvdimmd.c @@ -0,0 +1,315 @@ +/* + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ + +/* + * This program is used to provide nvdimm daemon necessary functions. + */ + +#include +#include +#include +#include +#include +#include +#include "libnvdimmd.h" + +void log_syslog(struct ndctl_ctx *ctx, int priority, const char *file, + int line, const char *fn, const char *format, va_list args) +{ + char buf[BUF_SIZE]; + struct log_ctx *log_ctx; + + log_ctx = >ctx; + vsnprintf(buf, sizeof(buf), format, args); + syslog(priority, "%s: %s: %s", log_ctx->owner, fn, buf); +} + +void log_file(struct ndctl_ctx *ctx, int priority, const char *file, + int line, const char *fn, const char *format, va_list args) +{ + DIR *dir; + FILE *f; + time_t c_time; + char date[32], buf[BUF_SIZE]; + char *filename; + int len = strlen(nvdimmd_cf->logfile) + strlen("/var/log/nvdimmd/"); + + filename = (char *) malloc(len); + strcpy(filename, "/var/log/nvdimmd/"); + strcat(filename, nvdimmd_cf->logfile); + + dir = opendir("/var/log/nvdimmd"); + if (dir) { + if (get_size(filename) >= 2000) + logrotate(filename); + } else { + if (mkdir("/var/log/nvdimmd", 0744) == -1) { + syslog(LOG_ERR, "cannot make dir /var/log/nvdimmd\n"); + exit(EXIT_FAILURE); + } + } + + f = fopen(filename, "a+"); + if (f == NULL) { + syslog(LOG_ERR, "%s cannot be opened\n", filename); + exit(EXIT_FAILURE); + } + + c_time = time(NULL); + strftime(date, sizeof(date), "%Y/%m/%d %H:%M:%S", localtime(_time)); + vsnprintf(buf, sizeof(buf), format, args); + fprintf(f, "%s [%u] %s: %s\n", date, (int)getpid(), fn, buf); + fclose(f); + free(filename); +} + +static char *get_json_msg(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm) +{ + struct json_object *jdimm, *jhealth; + char *msg; + + msg = (char *) malloc(1024); + msg[0] = '\0'; + jdimm = util_dimm_to_json(t_dimm->dimm, 0); + if (!jdimm) { + printf("no jdimm"); + } + jhealth = util_dimm_health_to_json(t_dimm->dimm); + if (jhealth) + json_object_object_add(jdimm, "health", jhealth); + else if (ndctl_dimm_is_cmd_supported(t_dimm->dimm, ND_CMD_SMART)) + dbg(ctx, "dimm [%s] do not support smart", t_dimm->devname); + else + dbg(ctx, "dimm [%s] can not get health info", t_dimm->devname); + + strcat(msg, json_object_to_json_string_ext(jdimm, + JSON_C_TO_STRING_PRETTY)); + return msg; +} + +static char *get_text_msg(struct ndctl_ctx *ctx, struct threshold_dimm *t_dimm) +{ + char *msg; + struct ndctl_cmd *cmd; + int rc; + unsigned int flags; + + msg = (char *) malloc(1024); + msg[0] = '\0'; + strcat(msg, "dev: "); + strcat(msg, t_dimm->devname); + strcat(msg, "\n health_state: "); + + cmd = ndctl_dimm_cmd_new_smart(t_dimm->dimm); + if (!cmd) { + dbg(ctx, "new smart command error"); + goto out; + } + + rc = ndctl_cmd_submit(cmd); + if (rc || ndctl_cmd_get_firmware_status(cmd)) { + dbg(ctx, "subbmit smart command error"); + goto out; + } + + flags = ndctl_cmd_smart_get_flags(cmd); + if (flags & ND_SMART_HEALTH_VALID) { + unsigned int health = ndctl_cmd_smart_get_health(cmd); + if (health & ND_SMART_FATAL_HEALTH) + strcat(msg, "fatal"); + else if (health & ND_SMART_CRITICAL_HEALTH) + strcat(msg, "critical"); + else if (health &
[RFC PATCH v2 2/7] ndctl: nvdimmd: add nvdimmd necessary util functions
This patch is used to provide helper functions needed for nvdimm daemon. These util functions can be used by other features as well in the future. Signed-off-by: QI Fuli--- nvdimmd/util.c | 80 ++ nvdimmd/util.h | 33 2 files changed, 113 insertions(+) create mode 100644 nvdimmd/util.c create mode 100644 nvdimmd/util.h diff --git a/nvdimmd/util.c b/nvdimmd/util.c new file mode 100644 index 000..ef6819e --- /dev/null +++ b/nvdimmd/util.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ + +#include +#include +#include +#include "util.h" + +void logrotate(char *file) +{ + time_t c_time; + char buf[4096], tstamp[32]; + + c_time = time(NULL); + strftime(tstamp, sizeof(tstamp), ".%Y%m%d%H%M%S", localtime(_time)); + strcpy(buf, file); + strcat(buf, tstamp); + rename(file, buf); +} + +long get_size(char *file) +{ + struct stat buf; + if (stat(file, ) == 0) + return buf.st_size; + return -1L; +} + +char *set_string(char **str, const char *value) +{ + *str = strdup(value); + return *str; +} + +char *trim_string(char *str) +{ + char *start; + char *end; + int len = strlen(str); + + if (len == 0) + return NULL; + + if (str[len-1] == '\n') { + len--; + str[len] = 0; + } + + start = str; + end = str + len - 1; + while(*start && isspace(*start)) + start++; + while(*end && isspace(*end)) + *end-- = 0; + strcpy(str, start); + return str; +} + +int split_string(char *str, const char *deli, char *outlist[]) +{ + int cnt = 0; + char *temp; + + temp = strtok(str, deli); + while (temp != NULL && cnt < NUM_MAX_DIMM) { + outlist[cnt++] = temp; + temp = strtok(NULL, deli); + } + return cnt; +} diff --git a/nvdimmd/util.h b/nvdimmd/util.h new file mode 100644 index 000..9648256 --- /dev/null +++ b/nvdimmd/util.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, FUJITSU LIMITED. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU Lesser General Public License, + * version 2.1, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + */ + +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include +#include +#include +#include +#define NUM_MAX_DIMM 1024 + +void logrotate(char *file); + +long get_size(char *file); + +char *set_string(char **str, const char *value); + +char *trim_string(char *str); + +int split_string(char *str, const char *deli, char *outlist[]); + +#endif -- 2.9.5 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 5/7] ndctl: nvdimmd: add nvdimmd config file
This patch adds nvdimmd.conf. Autotools to install the config file for nvdimmd service. The nvdimmd.conf includs the following parameters. - LOGFILE: Users can choose either to write the notifications into syslog (LOGFILE=syslog), or to send into a special file under /var/log/nvdimmd/ (such as LOGFILE=nvdimmd.log) by configuring LOGFILE parameter in the config file. - LOGFORMAT: Users can choose the format of notification to be structured json(LOGFORMAT=json) or text(LOGFORMAT=text) by configuring LOGFORMAT parameter in the config file. - MONITORDIMM: The dimms to monitor are filtered via dimm's name by setting MONITORDIMM parameter in the config file. When setting up multiple dimms, the names of dimms should be separated by ",".(MONITORDIMM=nmem0,nmem1,nmem2) - MONITORBUS: The dimms to monitor are filtered via its parent bus by setting MONITORBUS parameter as well. When setting up multiple dimms, the names of buses should be separated by "," (MONITORBUS=ndbus0,ndbus1) The nvdimmd.conf would be read when nvdimmd service starts. Users need to restart nvdimmd service after changing the value of paramaters in nvdimmd.conf. Signed-off-by: QI Fuli--- nvdimmd/Makefile.am | 9 + nvdimmd/nvdimmd.conf | 25 + 2 files changed, 34 insertions(+) create mode 100644 nvdimmd/nvdimmd.conf diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am index 9883edd..6716547 100644 --- a/nvdimmd/Makefile.am +++ b/nvdimmd/Makefile.am @@ -17,3 +17,12 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \ $(JSON_LIBS) \ $(UUID_LIBS) \ $(UDEV_LIBS) + +conffiles = nvdimmd.conf + +confdir = /etc/nvdimmd/ + +conf_DATA = $(conffiles) + +EXTRA_DIST =\ + $(conffiles) diff --git a/nvdimmd/nvdimmd.conf b/nvdimmd/nvdimmd.conf new file mode 100644 index 000..4e6a12a --- /dev/null +++ b/nvdimmd/nvdimmd.conf @@ -0,0 +1,25 @@ +# This is the main Nvdimm daemon configuration file. It contains the +# configuration directives that give nvdimmd its instructions. +# You can change settings by editing this file. +# The changed item will work after restart nvdimmd service. +# In this file, lines starting with a hash (#) are comments. +# The following charecters are not allowed the value: : # ? / \ % " ' + +# LOGFILE: Users can choose either to write the notifications into syslog +# (LOGFILE=syslog), or to send into a special file under /var/log/nvdimmd/ +# (such as LOGFILE=nvdimmd.log) by setting LOGFILE. +LOGFILE=nvdimmd.log + +# LOGFORMAT: Users can choose the format of notification to be json +# (LOGFORMAT=json) or text(LOGFORMAT=text) by setting LOGFORMAT. +LOGFORMAT = json + +# MONITORDIMM: The dimms to monitor are filtered via dimm's name by setting +# MONITORDIMM. When setting up mutiple dimms, the names of dimms should be +# separated by ",".(MONITORDIMM=nmem0,nmem1,nmem2) +MONITORDIMM=all + +# MONITORBUS: The dimms to monitor are filtered via its parent bus by +# setting as well. When setting up mutiple dimms, the names of buses +# should be seprated by "," (MONITORBUS=ndbus0,ndbus1) +MONITORBUS=all -- 2.9.5 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[RFC PATCH v2 6/7] ndctl: nvdimmd: add the unit file of systemd for nvdimmd service
This patch adds and autotools to install the unit file of systemd for nvdimmd service. Signed-off-by: QI Fuli--- nvdimmd/Makefile.am | 7 +++ nvdimmd/nvdimmd.service | 7 +++ 2 files changed, 14 insertions(+) create mode 100644 nvdimmd/nvdimmd.service diff --git a/nvdimmd/Makefile.am b/nvdimmd/Makefile.am index 6716547..bca0bc8 100644 --- a/nvdimmd/Makefile.am +++ b/nvdimmd/Makefile.am @@ -18,6 +18,12 @@ nvdimmd_LDADD = ../ndctl/lib/libndctl.la \ $(UUID_LIBS) \ $(UDEV_LIBS) +unitfiles = nvdimmd.service + +unitdir = /usr/lib/systemd/system/ + +unit_DATA = $(unitfiles) + conffiles = nvdimmd.conf confdir = /etc/nvdimmd/ @@ -25,4 +31,5 @@ confdir = /etc/nvdimmd/ conf_DATA = $(conffiles) EXTRA_DIST =\ + $(unitfiles) \ $(conffiles) diff --git a/nvdimmd/nvdimmd.service b/nvdimmd/nvdimmd.service new file mode 100644 index 000..0b96aaa --- /dev/null +++ b/nvdimmd/nvdimmd.service @@ -0,0 +1,7 @@ +[Unit] +Description=Nvdimm Daemon + +[Service] +Type=forking +ExecStart=/usr/bin/nvdimmd +ExecStop=/usr/bin/kill ${MAINPID} -- 2.9.5 ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [RFC patch v2 0/7] ndctl: nvdimmd: notify/monitor the feathers of over threshold event
I am sorry that Imadea mistake encoding this mail. I havesent a new one. Please ignore this mail. ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH 18/18] xfs: support for synchronous DAX faults
On Wed, Nov 01, 2017 at 04:36:47PM +0100, Jan Kara wrote: > From: Christoph Hellwig> > Return IOMAP_F_DIRTY from xfs_file_iomap_begin() when asked to prepare > blocks for writing and the inode is pinned, and has dirty fields other > than the timestamps. In __xfs_filemap_fault() we then detect this case > and call dax_finish_sync_fault() to make sure all metadata is committed, > and to insert the page table entry. > > Note that this will also dirty corresponding radix tree entry which is > what we want - fsync(2) will still provide data integrity guarantees for > applications not using userspace flushing. And applications using > userspace flushing can avoid calling fsync(2) and thus avoid the > performance overhead. > > [JK: Added VM_SYNC flag handling] > > Reviewed-by: Ross Zwisler > Signed-off-by: Christoph Hellwig > Signed-off-by: Jan Kara Looks ok, Reviewed-by: Darrick J. Wong > --- > fs/xfs/xfs_file.c | 15 ++- > fs/xfs/xfs_iomap.c | 5 + > 2 files changed, 19 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 4496b45678de..4827e82d5d2c 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > > static const struct vm_operations_struct xfs_file_vm_ops; > > @@ -1040,7 +1041,11 @@ __xfs_filemap_fault( > > xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); > if (IS_DAX(inode)) { > - ret = dax_iomap_fault(vmf, pe_size, NULL, _iomap_ops); > + pfn_t pfn; > + > + ret = dax_iomap_fault(vmf, pe_size, , _iomap_ops); > + if (ret & VM_FAULT_NEEDDSYNC) > + ret = dax_finish_sync_fault(vmf, pe_size, pfn); > } else { > if (write_fault) > ret = iomap_page_mkwrite(vmf, _iomap_ops); > @@ -1110,6 +1115,13 @@ xfs_file_mmap( > struct file *filp, > struct vm_area_struct *vma) > { > + /* > + * We don't support synchronous mappings for non-DAX files. At least > + * until someone comes with a sensible use case. > + */ > + if (!IS_DAX(file_inode(filp)) && (vma->vm_flags & VM_SYNC)) > + return -EOPNOTSUPP; > + > file_accessed(filp); > vma->vm_ops = _file_vm_ops; > if (IS_DAX(file_inode(filp))) > @@ -1128,6 +1140,7 @@ const struct file_operations xfs_file_operations = { > .compat_ioctl = xfs_file_compat_ioctl, > #endif > .mmap = xfs_file_mmap, > + .mmap_supported_flags = MAP_SYNC, > .open = xfs_file_open, > .release= xfs_file_release, > .fsync = xfs_file_fsync, > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index f179bdf1644d..b43be199fbdf 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -33,6 +33,7 @@ > #include "xfs_error.h" > #include "xfs_trans.h" > #include "xfs_trans_space.h" > +#include "xfs_inode_item.h" > #include "xfs_iomap.h" > #include "xfs_trace.h" > #include "xfs_icache.h" > @@ -1086,6 +1087,10 @@ xfs_file_iomap_begin( > trace_xfs_iomap_found(ip, offset, length, 0, ); > } > > + if ((flags & IOMAP_WRITE) && xfs_ipincount(ip) && > + (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) > + iomap->flags |= IOMAP_F_DIRTY; > + > xfs_bmbt_to_iomap(ip, iomap, ); > > if (shared) > -- > 2.12.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [PATCH] fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
On Mon, Nov 13, 2017 at 05:27:54PM -0800, Dan Williams wrote: > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index b43be199fbdf..888b60189983 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -1087,9 +1087,9 @@ xfs_file_iomap_begin( > trace_xfs_iomap_found(ip, offset, length, 0, ); > } > > - if ((flags & IOMAP_WRITE) && xfs_ipincount(ip) && > - (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) > - iomap->flags |= IOMAP_F_DIRTY; > + if (xfs_ipincount(ip)) > + if (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP) > + iomap->flags |= IOMAP_F_DIRTY; Please make a helper for this, and use it in xfs_file_fsync() where the same dirty checks are done. e.g. static inline bool xfs_inode_need_fsync(struct xfs_inode *ip, bool datasync) { if (!xfs_ipincount(ip)) return false; if (xfs_inode_clean(ip)) return false; if (datasync && !(ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) return false; return true; } Cheers, Dave. -- Dave Chinner da...@fromorbit.com ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 1/2] ndctl: daxctl: fix mmap size
The size for mmap needs to be aligned to the region alignment. Fix the mapping size so that it satisfy the alignment requirement. Signed-off-by: Dave Jiang--- daxctl/io.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/daxctl/io.c b/daxctl/io.c index 2f8cb4a..e739d0e 100644 --- a/daxctl/io.c +++ b/daxctl/io.c @@ -55,6 +55,7 @@ struct io_dev { struct ndctl_region *region; struct ndctl_dax *dax; uint64_t size; + uint64_t mmap_size; }; static struct { @@ -83,6 +84,7 @@ static bool is_stdinout(struct io_dev *io_dev) static int setup_device(struct io_dev *io_dev, size_t size) { int flags, rc; + unsigned long align; if (is_stdinout(io_dev)) return 0; @@ -104,8 +106,14 @@ static int setup_device(struct io_dev *io_dev, size_t size) if (!io_dev->is_dax) return 0; + align = ndctl_dax_get_align(io_dev->dax); + if (align == ULLONG_MAX) + return -ERANGE; + + io_dev->mmap_size = ALIGN(size, align); flags = (io_dev->direction == IO_READ) ? PROT_READ : PROT_WRITE; - io_dev->mmap = mmap(NULL, size, flags, MAP_SHARED, io_dev->fd, 0); + io_dev->mmap = mmap(NULL, io_dev->mmap_size, flags, + MAP_SHARED, io_dev->fd, 0); if (io_dev->mmap == MAP_FAILED) { rc = -errno; perror("mmap"); @@ -501,6 +509,8 @@ static void cleanup(void) for (i = 0; i < 2; i++) { if (is_stdinout([i])) continue; + if (io.dev[i].mmap_size) + munmap(io.dev[i].mmap, io.dev[i].mmap_size); close(io.dev[i].fd); } } ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[PATCH v2 2/2] ndctl: make mmap start at the offset
Instead of mmap at the beginning of the DAX region, map at the offset that is aligned down. This reduces the mmap size we need to create. Signed-off-by: Dave Jiang--- daxctl/io.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/daxctl/io.c b/daxctl/io.c index e739d0e..ce02f28 100644 --- a/daxctl/io.c +++ b/daxctl/io.c @@ -46,6 +46,7 @@ struct io_dev { const char *parm_path; char *real_path; uint64_t offset; + int offset_diff; enum io_direction direction; bool is_dax; bool is_char; @@ -84,7 +85,7 @@ static bool is_stdinout(struct io_dev *io_dev) static int setup_device(struct io_dev *io_dev, size_t size) { int flags, rc; - unsigned long align; + unsigned long align, offset; if (is_stdinout(io_dev)) return 0; @@ -112,8 +113,11 @@ static int setup_device(struct io_dev *io_dev, size_t size) io_dev->mmap_size = ALIGN(size, align); flags = (io_dev->direction == IO_READ) ? PROT_READ : PROT_WRITE; + offset = ALIGN_DOWN(io_dev->offset, align); + io_dev->offset_diff = io_dev->offset - offset; + io_dev->mmap = mmap(NULL, io_dev->mmap_size, flags, - MAP_SHARED, io_dev->fd, 0); + MAP_SHARED, io_dev->fd, offset); if (io_dev->mmap == MAP_FAILED) { rc = -errno; perror("mmap"); @@ -372,17 +376,17 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, ssize_t rc, count = 0; if (zero && dst_dev->is_dax) { - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; memset(dst, 0, len); pmem_persist(dst, len); rc = len; } else if (dst_dev->is_dax && src_dev->is_dax) { - src = (uint8_t *)src_dev->mmap + src_dev->offset; - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + src = (uint8_t *)src_dev->mmap + src_dev->offset_diff; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; pmem_memcpy_persist(dst, src, len); rc = len; } else if (src_dev->is_dax) { - src = (uint8_t *)src_dev->mmap + src_dev->offset; + src = (uint8_t *)src_dev->mmap + src_dev->offset_diff; if (dst_dev->offset) { rc = lseek(dst_dev->fd, dst_dev->offset, SEEK_SET); if (rc < 0) { @@ -407,7 +411,7 @@ static int64_t __do_io(struct io_dev *dst_dev, struct io_dev *src_dev, printf("Requested size %lu larger than source.\n", len); } else if (dst_dev->is_dax) { - dst = (uint8_t *)dst_dev->mmap + dst_dev->offset; + dst = (uint8_t *)dst_dev->mmap + dst_dev->offset_diff; if (src_dev->offset) { rc = lseek(src_dev->fd, src_dev->offset, SEEK_SET); if (rc < 0) { ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
[ndctl PATCH] libdaxctl: use the same uuid definition as libdaxctl
libdaxtl inadvertently included the uuid-devel version of the uuid.h header rather than the libuuid header. Fix this up to avoid type conflicts for applications that include both libdaxctl.h and libndctl.h. Reported-by: Lukasz PlewaSigned-off-by: Dan Williams --- daxctl/libdaxctl.h |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h index 77f6a25d2e30..21bc376ce629 100644 --- a/daxctl/libdaxctl.h +++ b/daxctl/libdaxctl.h @@ -15,7 +15,12 @@ #include #include -#include + +#ifdef HAVE_LIBUUID +#include +#else +typedef unsigned char uuid_t[16]; +#endif #ifdef __cplusplus extern "C" { ___ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm