Re: [Ocfs2-devel] [PATCH] ocfs2: retry on ENOSPC if sufficient space in truncate log
NAK, if ocfs2_try_to_free_truncate_log fails, it will lead to double ocfs2_inode_unlock and then BUG. On 2016/6/22 17:07, Eric Ren wrote: > The testcase "mmaptruncate" in ocfs2 test suite always fails with > ENOSPC error on small volume (say less than 10G). This testcase > creates 2 threads T1/T2 which race to "truncate"/"extend" a same > file repeatedly. Specifically, T1 truncates 1/2 size of a small file > while T2 extend to 100% size. The main bitmap will quickly run out > of space because the "truncate" code prevent truncate log from being > flushed by ocfs2_schedule_truncate_log_flush(osb, 1), while truncate > log may have cached lots of clusters. > > So retry to allocate after flushing truncate log when ENOSPC is > returned. And we cannot reuse the deleted blocks before the transaction > committed. Fortunately, we already have a function to do this - > ocfs2_try_to_free_truncate_log(). Just need to remove the "static" > modifier and put it into a right place. > > Signed-off-by: Eric Ren > --- > fs/ocfs2/alloc.c| 37 + > fs/ocfs2/alloc.h| 2 ++ > fs/ocfs2/aops.c | 37 - > fs/ocfs2/suballoc.c | 17 - > 4 files changed, 55 insertions(+), 38 deletions(-) > > diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c > index 460c0ce..7dabbc3 100644 > --- a/fs/ocfs2/alloc.c > +++ b/fs/ocfs2/alloc.c > @@ -6106,6 +6106,43 @@ void ocfs2_schedule_truncate_log_flush(struct > ocfs2_super *osb, > } > } > > +/* > + * Try to flush truncate logs if we can free enough clusters from it. > + * As for return value, "< 0" means error, "0" no space and "1" means > + * we have freed enough spaces and let the caller try to allocate again. > + */ > +int ocfs2_try_to_free_truncate_log(struct ocfs2_super *osb, > + unsigned int needed) > +{ > + tid_t target; > + int ret = 0; > + unsigned int truncated_clusters; > + > + inode_lock(osb->osb_tl_inode); > + truncated_clusters = osb->truncated_clusters; > + inode_unlock(osb->osb_tl_inode); > + > + /* > + * Check whether we can succeed in allocating if we free > + * the truncate log. > + */ > + if (truncated_clusters < needed) > + goto out; > + > + ret = ocfs2_flush_truncate_log(osb); > + if (ret) { > + mlog_errno(ret); > + goto out; > + } > + > + if (jbd2_journal_start_commit(osb->journal->j_journal, &target)) { > + jbd2_log_wait_commit(osb->journal->j_journal, target); > + ret = 1; > + } > +out: > + return ret; > +} > + > static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, > int slot_num, > struct inode **tl_inode, > diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h > index f3dc1b0..4a5152e 100644 > --- a/fs/ocfs2/alloc.h > +++ b/fs/ocfs2/alloc.h > @@ -188,6 +188,8 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, > u64 start_blk, > unsigned int num_clusters); > int __ocfs2_flush_truncate_log(struct ocfs2_super *osb); > +int ocfs2_try_to_free_truncate_log(struct ocfs2_super *osb, > +unsigned int needed); > > /* > * Process local structure which describes the block unlinks done > diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c > index c034edf..1802aef 100644 > --- a/fs/ocfs2/aops.c > +++ b/fs/ocfs2/aops.c > @@ -1645,43 +1645,6 @@ static int ocfs2_zero_tail(struct inode *inode, struct > buffer_head *di_bh, > return ret; > } > > -/* > - * Try to flush truncate logs if we can free enough clusters from it. > - * As for return value, "< 0" means error, "0" no space and "1" means > - * we have freed enough spaces and let the caller try to allocate again. > - */ > -static int ocfs2_try_to_free_truncate_log(struct ocfs2_super *osb, > - unsigned int needed) > -{ > - tid_t target; > - int ret = 0; > - unsigned int truncated_clusters; > - > - inode_lock(osb->osb_tl_inode); > - truncated_clusters = osb->truncated_clusters; > - inode_unlock(osb->osb_tl_inode); > - > - /* > - * Check whether we can succeed in allocating if we free > - * the truncate log. > - */ > - if (truncated_clusters < needed) > - goto out; > - > - ret = ocfs2_flush_truncate_log(osb); > - if (ret) { > - mlog_errno(ret); > - goto out; > - } > - > - if (jbd2_journal_start_commit(osb->journal->j_journal, &target)) { > - jbd2_log_wait_commit(osb->journal->j_journal, target); > - ret = 1; > - } > -out: > - return ret; > -} > - > int ocfs2_write_begin_nolock(struct address_space *mapping, >loff_t pos, unsigned len, ocfs2_write_type_t type, >struct
[Ocfs2-devel] [PATCH v3 00/24] Delete CURRENT_TIME_SEC and replace current_fs_time()
The series is aimed at getting rid of CURRENT_TIME, CURRENT_TIME_SEC macros and replacing current_fs_time() with current_time(). The macros are not y2038 safe. There is no plan to transition them into being y2038 safe. ktime_get_* api's can be used in their place. And, these are y2038 safe. CURRENT_TIME will be deleted after 4.8 rc1 as there is a dependency function time64_to_tm() for one of the CURRENT_TIME occurance. Thanks to Arnd Bergmann for all the guidance and discussions. Patches 3-5 were mostly generated using coccinelle. All filesystem timestamps use current_fs_time() for right granularity as mentioned in the respective commit texts of patches. This has a changed signature, renamed to current_time() and moved to the fs/inode.c. This series also serves as a preparatory series to transition vfs to 64 bit timestamps as outlined here: https://lkml.org/lkml/2016/2/12/104 . As per Linus's suggestion in https://lkml.org/lkml/2016/5/24/663 , all the inode timestamp changes have been squashed into a single patch. Also, current_time() now is used as a single generic vfs filesystem timestamp api. It also takes struct inode* as argument instead of struct super_block*. Posting all patches together in a bigger series so that the big picture is clear. As per the suggestion in https://lwn.net/Articles/672598/, CURRENT_TIME macro bug fixes are being handled in a series separate from transitioning vfs to use. Changes since v2: * Fix buildbot error for uninitalized sb in inode. * Minor fixes according to Arnd's comments. * Leave out the fnic and deletion of CURRENT_TIME to be submitted after 4.8 rc1. Deepa Dinamani (24): vfs: Add current_time() api fs: proc: Delete inode time initializations in proc_alloc_inode() fs: Replace CURRENT_TIME with current_time() for inode timestamps fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps fs: Replace current_fs_time() with current_time() fs: jfs: Replace CURRENT_TIME_SEC by current_time() fs: ext4: Use current_time() for inode timestamps fs: ubifs: Replace CURRENT_TIME_SEC with current_time fs: btrfs: Use ktime_get_real_ts for root ctime fs: udf: Replace CURRENT_TIME with current_time() fs: cifs: Replace CURRENT_TIME by current_time() fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts() fs: cifs: Replace CURRENT_TIME by get_seconds fs: f2fs: Use ktime_get_real_seconds for sit_info times drivers: staging: lustre: Replace CURRENT_TIME with current_time() fs: ocfs2: Use time64_t to represent orphan scan times fs: ocfs2: Replace CURRENT_TIME with ktime_get_real_seconds() audit: Use timespec64 to represent audit timestamps fs: nfs: Make nfs boot time y2038 safe block: Replace CURRENT_TIME with ktime_get_real_ts libceph: Replace CURRENT_TIME with ktime_get_real_ts fs: ceph: Replace current_fs_time for request stamp time: Delete current_fs_time() function time: Delete CURRENT_TIME_SEC arch/powerpc/platforms/cell/spufs/inode.c | 2 +- arch/s390/hypfs/inode.c| 4 +-- drivers/block/rbd.c| 2 +- drivers/char/sonypi.c | 2 +- drivers/infiniband/hw/qib/qib_fs.c | 2 +- drivers/misc/ibmasm/ibmasmfs.c | 2 +- drivers/oprofile/oprofilefs.c | 2 +- drivers/platform/x86/sony-laptop.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c| 16 ++-- drivers/staging/lustre/lustre/llite/namei.c| 4 +-- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 6 ++--- .../lustre/lustre/obdclass/linux/linux-obdo.c | 6 ++--- drivers/staging/lustre/lustre/obdclass/obdo.c | 6 ++--- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- drivers/usb/core/devio.c | 18 +++--- drivers/usb/gadget/function/f_fs.c | 8 +++--- drivers/usb/gadget/legacy/inode.c | 2 +- fs/9p/vfs_inode.c | 2 +- fs/adfs/inode.c| 2 +- fs/affs/amigaffs.c | 6 ++--- fs/affs/inode.c| 2 +- fs/attr.c | 2 +- fs/autofs4/inode.c | 2 +- fs/autofs4/root.c | 6 ++--- fs/bad_inode.c | 2 +- fs/bfs/dir.c | 14 +-- fs/binfmt_misc.c | 2 +- fs/btrfs/file.c| 6 ++--- fs/btrfs/inode.c | 22 fs/btrfs/ioctl.c | 8 +++--- fs/btrfs/root-tree.c | 3 ++- fs/btrfs/transaction.c | 4 +-- fs/btrfs/xattr.c | 2 +- fs/
Re: [Ocfs2-devel] [Y2038] [PATCH v3 00/24] Delete CURRENT_TIME_SEC and replace current_fs_time()
On Saturday, June 25, 2016 2:37:24 PM CEST Deepa Dinamani wrote: > The series is aimed at getting rid of CURRENT_TIME, CURRENT_TIME_SEC macros > and replacing current_fs_time() with current_time(). > The macros are not y2038 safe. There is no plan to transition them into being > y2038 safe. > ktime_get_* api's can be used in their place. And, these are y2038 safe. > > CURRENT_TIME will be deleted after 4.8 rc1 as there is a dependency function > time64_to_tm() for one of the CURRENT_TIME occurance. > > Thanks to Arnd Bergmann for all the guidance and discussions. > > Patches 3-5 were mostly generated using coccinelle. > > All filesystem timestamps use current_fs_time() for right granularity as > mentioned in the respective commit texts of patches. This has a changed > signature, renamed to current_time() and moved to the fs/inode.c. > > This series also serves as a preparatory series to transition vfs to 64 bit > timestamps as outlined here: https://lkml.org/lkml/2016/2/12/104 . > > As per Linus's suggestion in https://lkml.org/lkml/2016/5/24/663 , all the > inode timestamp changes have been squashed into a single patch. Also, > current_time() now is used as a single generic vfs filesystem timestamp api. > It also takes struct inode* as argument instead of struct super_block*. > Posting all patches together in a bigger series so that the big picture is > clear. > > As per the suggestion in https://lwn.net/Articles/672598/, CURRENT_TIME macro > bug fixes are being handled in a series separate from transitioning vfs to > use. > Everything in this version looks good to me. Please add Reviewed-by: Arnd Bergmann and send a pull request to Al Viro, based on the latest linux-4.7-rc release. Arnd ___ Ocfs2-devel mailing list Ocfs2-devel@oss.oracle.com https://oss.oracle.com/mailman/listinfo/ocfs2-devel
[Ocfs2-devel] ocfs2/dlm: fix memory leak of dlm_debug_ctxt
dlm_debug_ctxt->debug_refcnt is initialized to 1 and then increased to 2 by dlm_debug_get in dlm_debug_init. But dlm_debug_put is called only once in dlm_debug_shutdown during unregister dlm, which leads to dlm_debug_ctxt leaked. Signed-off-by: Joseph Qi Reviewed-by: Jiufei Xue --- fs/ocfs2/dlm/dlmdebug.c | 26 ++ fs/ocfs2/dlm/dlmdebug.h | 1 - 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c index 8251360..e7b760d 100644 --- a/fs/ocfs2/dlm/dlmdebug.c +++ b/fs/ocfs2/dlm/dlmdebug.c @@ -347,26 +347,6 @@ static struct dentry *dlm_debugfs_root; #define DLM_DEBUGFS_PURGE_LIST "purge_list" /* begin - utils funcs */ -static void dlm_debug_free(struct kref *kref) -{ - struct dlm_debug_ctxt *dc; - - dc = container_of(kref, struct dlm_debug_ctxt, debug_refcnt); - - kfree(dc); -} - -static void dlm_debug_put(struct dlm_debug_ctxt *dc) -{ - if (dc) - kref_put(&dc->debug_refcnt, dlm_debug_free); -} - -static void dlm_debug_get(struct dlm_debug_ctxt *dc) -{ - kref_get(&dc->debug_refcnt); -} - static int debug_release(struct inode *inode, struct file *file) { free_page((unsigned long)file->private_data); @@ -932,11 +912,9 @@ int dlm_debug_init(struct dlm_ctxt *dlm) goto bail; } - dlm_debug_get(dc); return 0; bail: - dlm_debug_shutdown(dlm); return -ENOMEM; } @@ -949,7 +927,8 @@ void dlm_debug_shutdown(struct dlm_ctxt *dlm) debugfs_remove(dc->debug_mle_dentry); debugfs_remove(dc->debug_lockres_dentry); debugfs_remove(dc->debug_state_dentry); - dlm_debug_put(dc); + kfree(dc); + dc = NULL; } } @@ -969,7 +948,6 @@ int dlm_create_debugfs_subroot(struct dlm_ctxt *dlm) mlog_errno(-ENOMEM); goto bail; } - kref_init(&dlm->dlm_debug_ctxt->debug_refcnt); return 0; bail: diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h index 1f27c48..5ced548 100644 --- a/fs/ocfs2/dlm/dlmdebug.h +++ b/fs/ocfs2/dlm/dlmdebug.h @@ -30,7 +30,6 @@ void dlm_print_one_mle(struct dlm_master_list_entry *mle); #ifdef CONFIG_DEBUG_FS struct dlm_debug_ctxt { - struct kref debug_refcnt; struct dentry *debug_state_dentry; struct dentry *debug_lockres_dentry; struct dentry *debug_mle_dentry; -- 1.8.4.3 ___ Ocfs2-devel mailing list Ocfs2-devel@oss.oracle.com https://oss.oracle.com/mailman/listinfo/ocfs2-devel