reiser4: discard support: initial implementation.
v6 cover reiser4: discard support: initial implementation.
v1: - initial implementation (patches 1, 2)
v2: - cleanup, fixes discovered in debug mode
- saner logging
- assertions
- enablement of discard through mount option
v3: - fixed the extent merge loop in discard_atom()
v4: - squashed fix-ups into the main patch (with exception of reiser4_debug())
- fixed bug in usage of division ops discovered while building on ARM
v5: - squashed mount option into the main patch
- refactor based on discussion (see commit msg)
- splitted off blocknr_list code
- replaced ->discard_set with ->delete_set and ->aux_delete_set
v6: - actualized in-code comments
- removed uber-verbose debug statements
- fixed code-to-patch mapping
- moved blocknrlist and blocknrset to kmem_cache instead of kmalloc/kfree (in a separate commit for ease of reviewing)
- dropped the RFC label
Ivan Shapovalov (5):
reiser4: make space_allocator's check_blocks() reusable.
reiser4: add an implementation of "block lists", splitted off the discard code.
reiser4: discard support: initial implementation using linked lists.
reiser4: blocknr_list: use kmem_cache instead of kmalloc for allocating entries.
reiser4: blocknr_set: use kmem_cache instead of kmalloc for allocating entries.
fs/reiser4/Makefile | 2 + fs/reiser4/block_alloc.c | 48 +++-- fs/reiser4/block_alloc.h | 14 +- fs/reiser4/blocknrlist.c | 336 ++++++++++++++++++++++++++++++ fs/reiser4/blocknrset.c | 34 ++- fs/reiser4/dformat.h | 2 + fs/reiser4/discard.c | 216 +++++++++++++++++++ fs/reiser4/discard.h | 31 +++ fs/reiser4/forward.h | 1 + fs/reiser4/init_super.c | 2 + fs/reiser4/plugin/space/bitmap.c | 84 +++++--- fs/reiser4/plugin/space/bitmap.h | 2 +- fs/reiser4/plugin/space/space_allocator.h | 4 +- fs/reiser4/super.h | 4 +- fs/reiser4/super_ops.c | 14 ++ fs/reiser4/txnmgr.c | 125 ++++++++++- fs/reiser4/txnmgr.h | 67 +++++- fs/reiser4/znode.c | 9 +- 18 files changed, 918 insertions(+), 77 deletions(-) create mode 100644 fs/reiser4/blocknrlist.c create mode 100644 fs/reiser4/discard.c create mode 100644 fs/reiser4/discard.h
Signature · 1 line
2.0.0
PATCH v6 1/5 reiser4: make space_allocator's check_blocks() reusable.
Make check_blocks() return a boolean value (whether did the extent's state match our expectations) instead of asserting success and crashing system otherwise.
Also make it possible to check extents spanning multiple bitmap blocks.
The only user of reiser4_check_block() in its previous form has been updated to assert on true return value.
Thus check_blocks() can now be reused by various parts of reiser4, e. g. by the discard subsystem which will be added in next commits.
--- fs/reiser4/block_alloc.c | 16 +----- fs/reiser4/block_alloc.h | 14 +++--- fs/reiser4/plugin/space/bitmap.c | 81 +++++++++++++++++++++---------- fs/reiser4/plugin/space/bitmap.h | 2 +- fs/reiser4/plugin/space/space_allocator.h | 4 +- fs/reiser4/znode.c | 9 ++-- 6 files changed, 72 insertions(+), 54 deletions(-)
fs/reiser4/block_alloc.c +2 -14
@@ -962,26 +962,14 @@ static void used2free(reiser4_super_info_data * sbinfo, __u64 count)spin_unlock_reiser4_super (sbinfo); } -#if REISER4_DEBUG -/* check "allocated" state of given block range */ -static void +int reiser4_check_blocks (const reiser4_block_nr * start,const reiser4_block_nr * len,int desired) { -sa_check_blocks (start, len, desired); +return sa_check_blocks (start, len, desired); } -/* check "allocated" state of given block */ -void reiser4_check_block (const reiser4_block_nr * block,int desired) -{ -const reiser4_block_nr one =1 ; - -reiser4_check_blocks (block, &one, desired); -} - -#endif -/* Blocks deallocation function may do an actual deallocation through space plugin allocation or store deleted block numbers in atom's delete_set data structure depend on @defer parameter. */
fs/reiser4/block_alloc.h +7 -7
@@ -150,15 +150,15 @@ extern void cluster_reserved2free(int count);extern int reiser4_check_block_counters (const struct super_block *); -#if REISER4_DEBUG -extern void reiser4_check_block (const reiser4_block_nr *,int ); +extern int reiser4_check_blocks (const reiser4_block_nr *start, +const reiser4_block_nr *len,int desired); -#else - -# define reiser4_check_block (beg, val) noop - -#endif +static inline int reiser4_check_block (const reiser4_block_nr *start, +int desired) +{ +return reiser4_check_blocks (start,NULL , desired); +}extern int reiser4_pre_commit_hook (void );extern void reiser4_post_commit_hook (void );
fs/reiser4/plugin/space/bitmap.c +55 -26
103 lines not on this page · raw message
fs/reiser4/plugin/space/bitmap.h +1 -1
@@ -19,7 +19,7 @@ extern int reiser4_alloc_blocks_bitmap(reiser4_space_allocator *, reiser4_blocknr_hint *, int needed, reiser4_block_nr * start, reiser4_block_nr * len); -extern void reiser4_check_blocks_bitmap (const reiser4_block_nr *, +extern int reiser4_check_blocks_bitmap (const reiser4_block_nr *,const reiser4_block_nr *,int ); extern void reiser4_dealloc_blocks_bitmap(reiser4_space_allocator *, reiser4_block_nr,
fs/reiser4/plugin/space/space_allocator.h +2 -2
@@ -29,9 +29,9 @@ static inline void sa_dealloc_blocks (reiser4_space_allocator * al, reiser4_bloc reiser4_dealloc_blocks_##allocator (al, start, len); \ } \ \ -static inline void sa_check_blocks (const reiser4_block_nr * start, const reiser4_block_nr * end, int desired) \ +static inline int sa_check_blocks (const reiser4_block_nr * start, const reiser4_block_nr * end, int desired) \ { \ - reiser4_check_blocks_##allocator (start, end, desired); \ + return reiser4_check_blocks_##allocator (start, end, desired); \ } \ \ static inline void sa_pre_commit_hook (void) \
fs/reiser4/znode.c +5 -4
@@ -534,10 +534,11 @@ znode *zget(reiser4_tree * tree,write_unlock_tree (tree); } -#if REISER4_DEBUG -if (!reiser4_blocknr_is_fake (blocknr) && *blocknr !=0 ) -reiser4_check_block (blocknr,1 ); -#endif + +assert ("intelfx-6" , +ergo (!reiser4_blocknr_is_fake (blocknr) && *blocknr !=0 , +reiser4_check_block (blocknr,1 ))); +/* Check for invalid tree level, return -EIO */ if (unlikely (znode_get_level (result) != level)) { warning("jmacd-504",
Signature · 1 line
2.0.0
PATCH v6 2/5 reiser4: add an implementation of "block lists", splitted off the discard code.
In reply to Ivan ShapovalovThe block list is a less memory efficient, but ordered (and thus sortable) implementation of the same concept as the blocknr_set.
--- fs/reiser4/Makefile | 1 + fs/reiser4/blocknrlist.c | 311 +++++++++++++++++++++++++++++++++++++++++++++++ fs/reiser4/forward.h | 1 + fs/reiser4/txnmgr.h | 19 +++ 4 files changed, 332 insertions(+) create mode 100644 fs/reiser4/blocknrlist.c
fs/reiser4/Makefile +1 -0
@@ -46,6 +46,7 @@ reiser4-y := \ status_flags.o \ init_super.o \ safe_link.o \ + blocknrlist.o \ \ plugin/plugin.o \ plugin/plugin_set.o \
fs/reiser4/blocknrlist.c new file +311 -0
311 lines not on this page · raw message
fs/reiser4/forward.h +1 -0
@@ -38,6 +38,7 @@ typedef struct reiser4_dir_entry_desc reiser4_dir_entry_desc;typedef struct reiser4_context reiser4_context ;typedef struct carry_level carry_level ;typedef struct blocknr_set_entry blocknr_set_entry ; +typedef struct blocknr_list_entry blocknr_list_entry ;/* super_block->s_fs_info points to this */ typedef struct reiser4_super_info_data reiser4_super_info_data ;/* next two objects are fields of reiser4_super_info_data */
fs/reiser4/txnmgr.h +19 -0
@@ -485,6 +485,25 @@ extern int blocknr_set_iterator(txn_atom * atom, struct list_head * bset, blocknr_set_actor_f actor, void *data, int delete); +/* This is the block list interface (see blocknrlist.c) */ +extern void blocknr_list_init (struct list_head *blist); +extern void blocknr_list_destroy (struct list_head *blist); +extern void blocknr_list_merge (struct list_head *from,struct list_head *to); +extern void blocknr_list_sort_and_join (struct list_head *blist); +/** +* The @atom should be locked. +*/ +extern int blocknr_list_add_extent (txn_atom *atom, +struct list_head *blist, +blocknr_list_entry **new_entry, +const reiser4_block_nr *start, +const reiser4_block_nr *len); +extern int blocknr_list_iterator (txn_atom *atom, +struct list_head *blist, +blocknr_set_actor_f actor, +void *data, +int delete); +/* flush code takes care about how to fuse flush queues */ extern void flush_init_atom (txn_atom * atom);extern void flush_fuse_queues (txn_atom * large,txn_atom * small);
Signature · 1 line
2.0.0
PATCH v6 3/5 reiser4: discard support: initial implementation using linked lists.
In reply to Ivan ShapovalovImplementation details:
- candidate extents are stored during the transaction to a linked list
- if an extent being added is adjacent to the last one, they are merged to prevent another allocation
- at commit time, the log is further sorted and extents are merged
- extents are further processed to align discard requests to erase unit boundaries, extending them to neighbour blocks if needed
- each erase unit is checked to be deallocated and submitted to discard
- processing stops at first failure (this does not fail atom commit)
For now (shortcomings):
- kernel-reported erase unit granularity and alignment offset are used as-is without any override (it may make sense in order to mitigate bogus values sometimes reported by kernel/hardware)
- processing each erase unit makes its own bitmap query to check allocation status; this is suboptimal when granularity is less than the block size (should not matter in practice as granularity almost never is that small)
Note on candidate block collection:
Another per-atom block set, ->aux_delete_set, has been added, containing extents deallocated without BA_DEFER (i. e. blocks of the wandered journal). When discard is enabled, storage of both delete sets is enabled. They are stored using blocknr_lists, then spliced and sorted before discarding, so all blocks that have been deallocated during the transaction are considered for discarding.
Otherwise, only ->delete_set is maintained, and it is stored using blocknr_set which is more memory efficient but inherently unordered (so it cannot be used for the discard algorithm).
The only semantic-significant change to existing code is that reiser4_post_commit_hook() does not clear ->delete_set (instead, it is cleared either by discard_atom() or as part of atom's destruction). This is OK because ->delete_set is not accessed after reiser4_post_commit_hook().
--- fs/reiser4/Makefile | 1 + fs/reiser4/block_alloc.c | 32 ++++-- fs/reiser4/dformat.h | 2 + fs/reiser4/discard.c | 216 +++++++++++++++++++++++++++++++++++++++ fs/reiser4/discard.h | 31 ++++++ fs/reiser4/init_super.c | 2 + fs/reiser4/plugin/space/bitmap.c | 3 +- fs/reiser4/super.h | 4 +- fs/reiser4/txnmgr.c | 125 ++++++++++++++++++++-- fs/reiser4/txnmgr.h | 44 +++++++- 10 files changed, 440 insertions(+), 20 deletions(-) create mode 100644 fs/reiser4/discard.c create mode 100644 fs/reiser4/discard.h
fs/reiser4/Makefile +1 -0
@@ -47,6 +47,7 @@ reiser4-y := \ init_super.o \ safe_link.o \ blocknrlist.o \ + discard.o \ \ plugin/plugin.o \ plugin/plugin_set.o \
fs/reiser4/block_alloc.c +24 -8
@@ -992,6 +992,7 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,int ret;reiser4_context *ctx;reiser4_super_info_data *sbinfo; +void *new_entry =NULL ; ctx =get_current_context (); sbinfo =get_super_private (ctx->super);
@@ -1007,17 +1008,13 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start, }if (flags &BA_DEFER ) { -blocknr_set_entry *bsep =NULL ; - -/* storing deleted block numbers in a blocknr set -datastructure for further actual deletion */ +/* store deleted block numbers in the atom's deferred delete set +for further actual deletion */ do { atom = get_current_atom_locked(); assert("zam-430", atom != NULL); - ret = - blocknr_set_add_extent(atom, &atom->delete_set, - &bsep, start, len); + ret = atom_dset_deferred_add_extent(atom, &new_entry, start, len); if (ret == -ENOMEM) return ret;
@@ -1031,6 +1028,25 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_atom (atom); }else { +/* store deleted block numbers in the atom's immediate delete set +for further processing */ +do { + atom =get_current_atom_locked (); +assert ("intelfx-51" , atom !=NULL ); + + ret =atom_dset_immediate_add_extent (atom, &new_entry, start, len); + +if (ret == -ENOMEM ) +return ret; + +/* This loop might spin at most two times */ + }while (ret == -E_REPEAT ); + +assert ("intelfx-52" , ret ==0 ); +assert ("intelfx-53" , atom !=NULL ); + +spin_unlock_atom (atom); +assert ("zam-425" ,get_current_super_private () !=NULL );sa_dealloc_blocks (reiser4_get_space_allocator (ctx->super), *start, *len);
@@ -1128,7 +1144,7 @@ void reiser4_post_commit_hook(void)/* do the block deallocation which was deferred until commit is done */ -blocknr_set_iterator (atom, &atom->delete_set, apply_dset,NULL ,1 ); +atom_dset_deferred_apply (atom, apply_dset,NULL ,0 );assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_commit_hook ();
fs/reiser4/dformat.h +2 -0
@@ -14,6 +14,8 @@#if !defined(__FS_REISER4_DFORMAT_H__)#define __FS_REISER4_DFORMAT_H__ +#include "debug.h" +#include <asm/byteorder.h> #include <asm/unaligned.h> #include <linux/types.h>
fs/reiser4/discard.c new file +216 -0
216 lines not on this page · raw message
fs/reiser4/discard.h new file +31 -0
@@ -0,0 +1,31 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by +* reiser4/README */ + +/* TRIM/discard interoperation subsystem for reiser4. */ + +#if !defined(__FS_REISER4_DISCARD_H__) +#define __FS_REISER4_DISCARD_H__ + +#include "forward.h" +#include "dformat.h" + +/** +* Issue discard requests for all block extents recorded in @atom's delete sets, +* if discard is enabled. In this case the delete sets are cleared. +* +* @atom should be locked on entry and is unlocked on exit. +*/ +extern int discard_atom (txn_atom *atom); + +/* __FS_REISER4_DISCARD_H__ */ +#endif + +/* Make Linus happy. +Local variables: +c-indentation-style: "K&R" +mode-name: "LC" +c-basic-offset: 8 +tab-width: 8 +fill-column: 120 +End: +*/
fs/reiser4/init_super.c +2 -0
@@ -494,6 +494,8 @@ int reiser4_init_super_data(struct super_block *super, char *opt_string)PUSH_BIT_OPT ("atomic_write" ,REISER4_ATOMIC_WRITE );/* disable use of write barriers in the reiser4 log writer. */ PUSH_BIT_OPT ("no_write_barrier" ,REISER4_NO_WRITE_BARRIER ); +/* enable issuing of discard requests */ +PUSH_BIT_OPT ("discard" ,REISER4_DISCARD ); PUSH_OPT(p, opts, {
fs/reiser4/plugin/space/bitmap.c +1 -2
@@ -1460,8 +1460,7 @@ int reiser4_pre_commit_hook_bitmap(void) } } -blocknr_set_iterator (atom, &atom->delete_set, apply_dset_to_commit_bmap, - &blocks_freed,0 ); +atom_dset_deferred_apply (atom, apply_dset_to_commit_bmap, &blocks_freed,0 ); blocks_freed -= atom->nr_blocks_allocated;
fs/reiser4/super.h +3 -1
@@ -51,7 +51,9 @@ typedef enum {/* enforce atomicity during write(2) */ REISER4_ATOMIC_WRITE =6 ,/* don't use write barriers in the log writer code. */ - REISER4_NO_WRITE_BARRIER = 7 +REISER4_NO_WRITE_BARRIER =7 , +/* enable issuing of discard requests */ + REISER4_DISCARD = 8 } reiser4_fs_flag;/*
fs/reiser4/txnmgr.c +119 -6
173 lines not on this page · raw message
fs/reiser4/txnmgr.h +41 -3
56 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v6 4/5 reiser4: blocknr_list: use kmem_cache instead of kmalloc for allocating entries.
In reply to Ivan Shapovalov--- fs/reiser4/blocknrlist.c | 31 ++++++++++++++++++++++++++++--- fs/reiser4/super_ops.c | 7 +++++++ fs/reiser4/txnmgr.h | 2 ++ 3 files changed, 37 insertions(+), 3 deletions(-)
fs/reiser4/blocknrlist.c +28 -3
@@ -9,10 +9,13 @@#include "dformat.h" #include "txnmgr.h" #include "context.h" +#include "super.h" #include <linux/slab.h> #include <linux/list_sort.h> +static struct kmem_cache *blocknr_list_slab =NULL ; +/** * Represents an extent range [@start; @end). */
@@ -36,8 +39,8 @@ static blocknr_list_entry *blocknr_list_entry_alloc(void) {blocknr_list_entry *entry; - entry = (blocknr_list_entry *)kmalloc (sizeof (blocknr_list_entry), -reiser4_ctx_gfp_mask_get ()); + entry = (blocknr_list_entry *)kmem_cache_alloc (blocknr_list_slab, +reiser4_ctx_gfp_mask_get ());if (entry ==NULL ) {return NULL ; }
@@ -51,7 +54,7 @@ static void blocknr_list_entry_free(blocknr_list_entry *entry) {assert ("intelfx-12" , entry !=NULL ); -kfree (entry); +kmem_cache_free (blocknr_list_slab, entry); }/**
@@ -142,6 +145,28 @@ static int blocknr_list_entry_compare(void* priv UNUSED_ARG,return 0 ; } +int blocknr_list_init_static (void ) +{ +assert ("intelfx-54" , blocknr_list_slab ==NULL ); + + blocknr_list_slab =kmem_cache_create ("blocknr_list_entry" , +sizeof (blocknr_list_entry), +0 , +SLAB_HWCACHE_ALIGN | +SLAB_RECLAIM_ACCOUNT , +NULL ); +if (blocknr_list_slab ==NULL ) { +return RETERR (-ENOMEM ); + } + +return 0 ; +} + +void blocknr_list_done_static (void ) +{ +destroy_reiser4_cache (&blocknr_list_slab); +} +void blocknr_list_init (struct list_head * blist) {assert ("intelfx-24" , blist !=NULL );
fs/reiser4/super_ops.c +7 -0
@@ -678,11 +678,17 @@ static int __init init_reiser4(void)if ((result =reiser4_init_d_cursor ()) !=0 ) goto failed_init_d_cursor; +/* initialize cache of blocknr list entries */ +if ((result =blocknr_list_init_static ()) !=0 ) + goto failed_init_blocknr_list; +if ((result =register_filesystem (&reiser4_fs_type)) ==0 ) { reiser4_debugfs_root =debugfs_create_dir ("reiser4" ,NULL );return 0 ; } +blocknr_list_done_static (); + failed_init_blocknr_list:reiser4_done_d_cursor (); failed_init_d_cursor:reiser4_done_file_fsdata ();
@@ -718,6 +724,7 @@ static void __exit done_reiser4(void)debugfs_remove (reiser4_debugfs_root); result =unregister_filesystem (&reiser4_fs_type);BUG_ON (result !=0 ); +blocknr_list_done_static ();reiser4_done_d_cursor ();reiser4_done_file_fsdata ();reiser4_done_dentry_fsdata ();
fs/reiser4/txnmgr.h +2 -0
@@ -503,6 +503,8 @@ extern int blocknr_set_iterator(txn_atom * atom, struct list_head * bset, int delete);/* This is the block list interface (see blocknrlist.c) */ +extern int blocknr_list_init_static (void ); +extern void blocknr_list_done_static (void );extern void blocknr_list_init (struct list_head *blist);extern void blocknr_list_destroy (struct list_head *blist);extern void blocknr_list_merge (struct list_head *from,struct list_head *to);
Signature · 1 line
2.0.0
PATCH v6 5/5 reiser4: blocknr_set: use kmem_cache instead of kmalloc for allocating entries.
In reply to Ivan Shapovalov--- fs/reiser4/blocknrset.c | 34 +++++++++++++++++++++++++++++++--- fs/reiser4/super_ops.c | 7 +++++++ fs/reiser4/txnmgr.h | 2 ++ 3 files changed, 40 insertions(+), 3 deletions(-)
fs/reiser4/blocknrset.c +31 -3
@@ -8,6 +8,7 @@ reiser4/README */#include "dformat.h" #include "txnmgr.h" #include "context.h" +#include "super.h" #include <linux/slab.h>
@@ -42,6 +43,8 @@ reiser4/README */ sizeof(struct list_head)) / \ sizeof(reiser4_block_nr)) +static struct kmem_cache *blocknr_set_slab =NULL ; +/* An entry of the blocknr_set */ struct blocknr_set_entry {unsigned nr_singles;
@@ -82,8 +85,8 @@ static blocknr_set_entry *bse_alloc(void) {blocknr_set_entry *e; -if ((e = (blocknr_set_entry *)kmalloc (sizeof (blocknr_set_entry), -reiser4_ctx_gfp_mask_get ())) ==NULL ) +if ((e = (blocknr_set_entry *)kmem_cache_alloc (blocknr_set_slab, +reiser4_ctx_gfp_mask_get ())) ==NULL )return NULL ;bse_init (e);
@@ -95,7 +98,7 @@ static blocknr_set_entry *bse_alloc(void)/* Audited by: green(2002.06.11) */ static void bse_free (blocknr_set_entry * bse) { -kfree (bse); +kmem_cache_free (blocknr_set_slab, bse); }/* Add a block number to a blocknr_set_entry */
@@ -225,6 +228,31 @@ blocknr_set_add_pair(txn_atom * atom,return blocknr_set_add (atom, bset, new_bsep, a, b); } +/* Initialize slab cache of blocknr_set_entry objects. */ +int blocknr_set_init_static (void ) +{ +assert ("intelfx-55" , blocknr_set_slab ==NULL ); + + blocknr_set_slab =kmem_cache_create ("blocknr_set_entry" , +sizeof (blocknr_set_entry), +0 , +SLAB_HWCACHE_ALIGN | +SLAB_RECLAIM_ACCOUNT , +NULL ); + +if (blocknr_set_slab ==NULL ) { +return RETERR (-ENOMEM ); + } + +return 0 ; +} + +/* Destroy slab cache of blocknr_set_entry objects. */ +void blocknr_set_done_static (void ) +{ +destroy_reiser4_cache (&blocknr_set_slab); +} +/* Initialize a blocknr_set. */ void blocknr_set_init (struct list_head *bset) {
fs/reiser4/super_ops.c +7 -0
@@ -678,6 +678,10 @@ static int __init init_reiser4(void)if ((result =reiser4_init_d_cursor ()) !=0 ) goto failed_init_d_cursor; +/* initialize cache of blocknr set entries */ +if ((result =blocknr_set_init_static ()) !=0 ) + goto failed_init_blocknr_set; +/* initialize cache of blocknr list entries */ if ((result =blocknr_list_init_static ()) !=0 ) goto failed_init_blocknr_list;
@@ -689,6 +693,8 @@ static int __init init_reiser4(void)blocknr_list_done_static (); failed_init_blocknr_list: +blocknr_set_done_static (); + failed_init_blocknr_set:reiser4_done_d_cursor (); failed_init_d_cursor:reiser4_done_file_fsdata ();
@@ -725,6 +731,7 @@ static void __exit done_reiser4(void) result =unregister_filesystem (&reiser4_fs_type);BUG_ON (result !=0 );blocknr_list_done_static (); +blocknr_set_done_static ();reiser4_done_d_cursor ();reiser4_done_file_fsdata ();reiser4_done_dentry_fsdata ();
fs/reiser4/txnmgr.h +2 -0
@@ -482,6 +482,8 @@ int capture_bulk(jnode **, int count);/* See the comment on the function blocknrset.c:blocknr_set_add for the calling convention of these three routines. */ +extern int blocknr_set_init_static (void ); +extern void blocknr_set_done_static (void );extern void blocknr_set_init (struct list_head * bset);extern void blocknr_set_destroy (struct list_head * bset);extern void blocknr_set_merge (struct list_head * from,struct list_head * into);
Signature · 1 line
2.0.0
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
In reply to Ivan ShapovalovOn 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...]
Quoted 18 lines
+++
b/fs/reiser4/discard.cfs/reiser4/discard.c new file +16
-0@@ -0,0 +1,216 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by +* reiser4/README */ + +/* TRIM/discard interoperation subsystem for reiser4. */ + +/* +* This subsystem is responsible for populating an atom's ->discard_set and +* (later) converting it into a series of discard calls to the kernel. +* +* The discard is an in-kernel interface for notifying the storage +* hardware about blocks that are being logically freed by the filesystem. +* This is done via calling the blkdev_issue_discard() function. There are +* restrictions on block ranges: they should constitute at least one erase unit +* in length and be correspondingly aligned. Otherwise a discard request will +* be ignored. +*
fs/reiser4/discard.c line 26
Quoted 10 lines
fs/reiser4/discard.c new file +10
-0+* The erase unit size is kept in struct queue_limits as discard_granularity. +* The offset from the partition start to the first erase unit is kept in +* struct queue_limits as discard_alignment. +* +* At atom level, we record numbers of all blocks that happen to be deallocated +* during the transaction. Then we read the generated set, filter out any blocks +* that have since been allocated again and issue discards for everything still +* valid. This is what discard.[ch] is here for. +* +* However, simply iterating through the recorded extents is not enough:
I still don't understand this explanation..
fs/reiser4/discard.c line 29
Quoted 3 lines
fs/reiser4/discard.c new file +3
-0+* - if a single extent is smaller than the erase unit, then this particular +* extent won't be discarded even if it is surrounded by enough free blocks +* to constitute a whole erase unit;
Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
fs/reiser4/discard.c line 31
Quoted 2 lines
fs/reiser4/discard.c new file +2
-0+* - we won't be able to merge small adjacent extents forming an extent long +* enough to be discarded.
At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?
Please, consider such possibility. Iterating over erase units in discard_extent() looks suboptimal.
Thanks,
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 26 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...]Quoted 23 lines
+++
b/fs/reiser4/discard.cfs/reiser4/discard.c new file +21
-0@@ -0,0 +1,216 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by +* reiser4/README */ + +/* TRIM/discard interoperation subsystem for reiser4. */ + +/* +* This subsystem is responsible for populating an atom's ->discard_set and +* (later) converting it into a series of discard calls to the kernel. +* +* The discard is an in-kernel interface for notifying the storage +* hardware about blocks that are being logically freed by the filesystem. +* This is done via calling the blkdev_issue_discard() function. There are +* restrictions on block ranges: they should constitute at least one erase unit +* in length and be correspondingly aligned. Otherwise a discard request will +* be ignored. +* +* The erase unit size is kept in struct queue_limits as discard_granularity. +* The offset from the partition start to the first erase unit is kept in +* struct queue_limits as discard_alignment. +* +* At atom level, we record numbers of all blocks that happen to be deallocated
Quoted 8 lines
fs/reiser4/discard.c line 26
Quoted 5 lines
fs/reiser4/discard.c new file +5
-0+* during the transaction. Then we read the generated set, filter out any blocks +* that have since been allocated again and issue discards for everything still +* valid. This is what discard.[ch] is here for. +* +* However, simply iterating through the recorded extents is not enough: I still don't understand this explanation..
In short: we need to "screen" those extents to check whether they are still free.
Quoted 9 lines
fs/reiser4/discard.c line 29
Quoted 5 lines
fs/reiser4/discard.c new file +3
-0+* - if a single extent is smaller than the erase unit, then this particular +* extent won't be discarded even if it is surrounded by enough free blocks +* to constitute a whole erase unit; Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 9 lines
fs/reiser4/discard.c line 31
Quoted 4 lines
fs/reiser4/discard.c new file +2
-0+* - we won't be able to merge small adjacent extents forming an extent long +* enough to be discarded. At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?
"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 4 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.
Yes, it's costly... but I don't see any other ways to do the task efficiently.
Signature · 1 line
Ivan Shapovalov / intelfx /
Quoted 3 lines
Thanks,
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 57 lines · Ivan Shapovalov
Quoted 24 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...]Quoted 22 lines
+++
b/fs/reiser4/discard.cfs/reiser4/discard.c new file +20
-0@@ -0,0 +1,216 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by +* reiser4/README */ + +/* TRIM/discard interoperation subsystem for reiser4. */ + +/* +* This subsystem is responsible for populating an atom's ->discard_set and +* (later) converting it into a series of discard calls to the kernel. +* +* The discard is an in-kernel interface for notifying the storage +* hardware about blocks that are being logically freed by the filesystem. +* This is done via calling the blkdev_issue_discard() function. There are +* restrictions on block ranges: they should constitute at least one erase unit +* in length and be correspondingly aligned. Otherwise a discard request will +* be ignored. +* +* The erase unit size is kept in struct queue_limits as discard_granularity. +* The offset from the partition start to the first erase unit is kept in +* struct queue_limits as discard_alignment. +* Quoted 8 lines
fs/reiser4/discard.c line 26
Quoted 6 lines
fs/reiser4/discard.c new file +6
-0+* At atom level, we record numbers of all blocks that happen to be deallocated +* during the transaction. Then we read the generated set, filter out any blocks +* that have since been allocated again and issue discards for everything still +* valid. This is what discard.[ch] is here for. +* +* However, simply iterating through the recorded extents is not enough: I still don't understand this explanation..
In short: we need to "screen" those extents to check whether they are still free.
Quoted 7 lines
fs/reiser4/discard.c line 29
Quoted 4 lines
fs/reiser4/discard.c new file +3
-0+* - if a single extent is smaller than the erase unit, then this particular +* extent won't be discarded even if it is surrounded by enough free blocks +* to constitute a whole erase unit; Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 8 lines
fs/reiser4/discard.c line 31
Quoted 3 lines
fs/reiser4/discard.c new file +2
-0+* - we won't be able to merge small adjacent extents forming an extent long +* enough to be discarded. "I don't believe" (c) K. Stanislavski
At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
"I don't believe!" (c) K. Stanislavski.
OK, I'll show my version of the discard-list-extents a bit later.. Please, consider implementation of the FITRIM ioctl based on the current discard functionality, if possible.
Thanks!
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
In reply to Ivan ShapovalovQuoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...]
[...]
Quoted 20 lines
Quoted 7 lines
Quoted 4 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 7 lines
Quoted 3 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.P.S. I tested it, but not enough.
--- fs/reiser4/blocknrlist.c | 10 + fs/reiser4/discard.c | 249 ++++++++++++++++++++++++++++++++++++++++++++++- fs/reiser4/txnmgr.h | 2 3 files changed, 259 insertions(+), 2 deletions(-)
fs/reiser4/discard.c +247 -2
@@ -167,6 +167,249 @@ static int discard_extent(txn_atom *atomreturn 0 ; } +/* +* Return size of head padding of an extent on a lattice +* with step @ulen and offset @uoff. +* @start - the start offset of the extent. +*/ +static int extent_get_headp (reiser4_block_nr start,int uoff,int ulen) +{ +__u64 headp; + headp = ulen + start - uoff; + headp =do_div (headp, ulen); +return headp; +} + +/* +* Return size of tail padding of an extent on a lattice +* with step @ulen and offset @uoff. +* @end - the end offset of the extent. +*/ +static int extent_get_tailp (reiser4_block_nr end,int uoff,int ulen) +{ +__u64 tailp; + tailp = ulen + end - uoff; + tailp =do_div (tailp, ulen); +if (tailp) + tailp = ulen - tailp; +return tailp; +} + +static struct list_head *get_next_at (struct list_head *pos, +struct list_head *head) +{ +assert ("edward-1631" , pos !=NULL ); +assert ("edward-1632" , head !=NULL ); +assert ("edward-1633" , pos != head); + +return pos->next == head ?NULL : pos->next; +} + +static inline int check_free_blocks (const reiser4_block_nr start, +const reiser4_block_nr len) +{ +return reiser4_check_blocks (&start, &len,0 ); +} + +/* Make sure that extents are sorted and merged */ +#if REISER4_DEBUG +static inline void check_blocknr_list_at (struct list_head *pos, +struct list_head *head) +{ +struct list_head *next; + + next =get_next_at (pos, head); +if (next ==NULL ) +return ; +if (blocknr_list_entry_start (next) <= +blocknr_list_entry_start (pos) +blocknr_list_entry_len (pos)) +warning ("edward-1634" , +"discard bad pair of extents: (%llu,%llu), (%llu,%llu)" , +blocknr_list_entry_start (pos), +blocknr_list_entry_len (pos), +blocknr_list_entry_start (next), +blocknr_list_entry_len (next)); +} +#else +#define check_blocknr_list_at (pos, head) noop +#endif + +/* +* discard_sorted_extents() - iterate through the list of +* sorted and merged extents and check head and tail paddings +* of each extent in the working space map. Try to "glue" the +* nearby extents. Discard the (glued) extents with padded (or +* cut) head and tail. +* +* Pre-conditions: @head points to the list of sorted and +* merged extents. +* +* Local variables: +* +* d_uni - discard unit size (in blocks); +* d_off - discard alignment (in blocks); +* +* start - offset of the first block of the extent; +* len - length of the extent; +* end - offset of the first block beyond extent; +* +* headp - size of head padding of the extent; +* tailp - size of tail padding of the extent; +* +* astart - actual start to discard (offset of the head padding); +* alen - actual length to discard (length of glued aligned and padded extents). +* +* Terminology in the comments: +* +* head - a part of extent at the beginning; +* tail - a part of extent at the end. +*/ + +static int discard_sorted_extents (struct list_head *head) +{ +int ret; +struct super_block *sb =reiser4_get_current_sb (); +struct queue_limits *limits = &bdev_get_queue (sb->s_bdev)->limits; + +int d_uni; +int d_off; +struct list_head *pos; + + d_uni = limits->discard_granularity / sb->s_blocksize; +if (d_uni ==0 ) + d_uni =1 ; + d_off = (bdev_discard_alignment (sb->s_bdev) / sb->s_blocksize) % d_uni; + +for (pos = head->next; pos != head; pos = pos->next) { +int headp; +int tailp; +int headp_is_known_dirty =0 ; +reiser4_block_nr start; +reiser4_block_nr len; +reiser4_block_nr end; +reiser4_block_nr astart;__s64 alen; + +check_blocknr_list_at (pos, head); + + start =blocknr_list_entry_start (pos); + len =blocknr_list_entry_len (pos); +/* +* Step I. Cut or pad the head of extent +* +* This extent wasn't glued +*/ + headp =extent_get_headp (start, d_off, d_uni); + +if (headp && !headp_is_known_dirty && +check_free_blocks (start - headp, headp)) { +/* +* head padding is clean, +* pad the head +*/ + astart = start - headp; + alen = len + headp; + } +else { +/* +* head padding is empty or dirty, +* cut the head +*/ + headp_is_known_dirty =0 ; + astart = start + (d_uni - headp); + alen = len - (d_uni - headp); + } +/* +* Step II. Try to glue all nearby extents to the tail +* Cut or pad the tail of the last extent. +*/ + end = start + len; + tailp =extent_get_tailp (end, d_off, d_uni); + +/* +* This "gluing" loop updates @pos, @end, @tailp, @alen +*/ +while (1 ) { +struct list_head *next; + + next =get_next_at (pos, head); +check_blocknr_list_at (next, head); + +if (next && (end + tailp >=blocknr_list_entry_start (next))) { +/* +* try to glue the next extent +*/ +reiser4_block_nr next_start; +reiser4_block_nr next_len; + + next_start =blocknr_list_entry_start (next); + next_len =blocknr_list_entry_len (next); + +if (check_free_blocks (end, next_start - end)) { +/* +* jump to the glued extent +*/ +if (end + tailp < next_start + next_len) { +/* +* the glued extent doesn't +* fit into the tail padding, +* so update the last one +*/ + tailp =extent_get_tailp (next_start + next_len, + d_off, d_uni); + alen += (next_start + next_len - end); + } + pos = next; + end = next_start + next_len; +/* +* try to glue more extents +*/ +continue ; + }else { +/* +* gluing failed, cut the tail +*/ +if (end + tailp > next_start) + headp_is_known_dirty =1 ; + + alen -= (d_uni - tailp); +break ; + } + }else { +/* +* nothing to glue: +* this is the last extent, or the next +* extent is too far. So just check the +* rest of tail padding +*/ +if (tailp &&check_free_blocks (end, tailp)) +/* +* tail padding is clean, +* pad the tail +*/ + alen += tailp; +else +/* +* empty or dirty tail padding, +* cut the tail +*/ + alen -= (d_uni - tailp); +break ; + } + } +/* +* Step III. Discard the result +*/ +if (alen >0 ) { + ret =__discard_extent (sb->s_bdev, + astart * (sb->s_blocksize >>9 ), + alen * (sb->s_blocksize >>9 )); +if (ret) +return ret; + } + } +return 0 ; +} +int discard_atom (txn_atom *atom) {int ret;
@@ -195,11 +438,13 @@ int discard_atom(txn_atom *atom)blocknr_list_sort_and_join (&discard_set);/* Perform actual dirty work. */ - ret =blocknr_list_iterator (NULL , &discard_set, &discard_extent,NULL ,1 ); + +//ret = blocknr_list_iterator(NULL, &discard_set, &discard_extent, NULL, 1); + + ret =discard_sorted_extents (&discard_set);if (ret !=0 ) {return ret; } -/* Let's do this again for any new extents in the atom's discard set. */ return -E_REPEAT ; }
fs/reiser4/blocknrlist.c +10 -0
@@ -26,6 +26,16 @@ struct blocknr_list_entry {#define blocknr_list_entry (ptr) list_entry(ptr, blocknr_list_entry, link) +reiser4_block_nr blocknr_list_entry_start (struct list_head *ptr) +{ +return blocknr_list_entry (ptr)->start; +} + +reiser4_block_nr blocknr_list_entry_len (struct list_head *ptr) +{ +return blocknr_list_entry (ptr)->len; +} +static void blocknr_list_entry_init (blocknr_list_entry *entry) {assert ("intelfx-11" , entry !=NULL );
fs/reiser4/txnmgr.h +2 -0
@@ -507,6 +507,8 @@ extern int blocknr_set_iterator(txn_atom/* This is the block list interface (see blocknrlist.c) */ extern int blocknr_list_init_static (void );extern void blocknr_list_done_static (void ); +extern reiser4_block_nr blocknr_list_entry_start (struct list_head *blist); +extern reiser4_block_nr blocknr_list_entry_len (struct list_head *blist);extern void blocknr_list_init (struct list_head *blist);extern void blocknr_list_destroy (struct list_head *blist);extern void blocknr_list_merge (struct list_head *from,struct list_head *to);
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 34 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 20 lines
Quoted 7 lines
Quoted 4 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 7 lines
Quoted 3 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
Quoted 7 lines
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.
P.S. I tested it, but not enough.
Hm. I'm probably a dumbass, but...
I don't see where the [start; start+len) region is checked for being free.
Also, btw, do we need to cut the head (lines 155-163 of the patch) if headp is empty? It seems that it would reduce extent by one whole erase unit without any justification.
But I like the idea of gluing padded extents together if possible...
Thanks,
Signature · 1 line
Ivan Shapovalov / intelfx /
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 35 lines · Ivan Shapovalov
Quoted 34 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 5 lines
Quoted 2 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Quoted 5 lines
Quoted 2 lines
Edward.
P.S. I tested it, but not enough.Hm. I'm probably a dumbass, but...
I don't see where the [start; start+len) region is checked for being free.
check_free_blocks() is called for this purpose.
Firstly when checking head padding. Secondly in the gluing loop (to glue 2 extents in particular means to make sure that region between them is free). Finally we check if the tail padding is free.
Quoted 4 lines
Also, btw, do we need to cut the head (lines 155-163 of the patch) if headp is empty? It seems that it would reduce extent by one whole erase unit without any justification.
Yes, this is definitely a leak of not discarded erase units. Is the attached version better?
Edward.
/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
* reiser4/README */
/* TRIM/discard interoperation subsystem for reiser4. */
/*
* This subsystem is responsible for populating an atom's "discard set" and
* (later) converting it into a series of discard calls to the kernel. *
* The discard is an in-kernel interface for notifying the storage
* hardware about blocks that are being logically freed by the filesystem.
* This is done via calling the blkdev_issue_discard() function. There are
* restrictions on block ranges: they should constitute at least one erase unit
* in length and be correspondingly aligned. Otherwise a discard request will
* be ignored.
*
* The erase unit size is kept in struct queue_limits as discard_granularity.
* The offset from the partition start to the first erase unit is kept in
* struct queue_limits as discard_alignment.
*
* At atom level, we record numbers of all blocks that happen to be deallocated
* during the transaction. Then we read the generated set, filter out any blocks
* that have since been allocated again and issue discards for everything still
* valid. This is what discard.[ch] is here for.
*
* MECHANISM:
*
* During the transaction deallocated extents are recorded in atom's delete
* sets. There are two delete sets, because data in one of them (delete_set) is
* also used by other parts of reiser4. The second delete set (aux_delete_set)
* complements the first one and is maintained only when discard is enabled. *
* Together these sets constitute "the discard set" -- blocks that have to be
* considered for discarding. On atom commit we will generate a minimal
* superset of the discard set, comprised of whole erase units.
*
* So, at commit time we:
* - merge the delete sets;
* - sort extents of the resulted discard set;
* - join adjacent extents of the discard set;
* - discard extenmts of the discard set.
*/
#include "discard.h"
#include "context.h"
#include "debug.h"
#include "txnmgr.h"
#include "super.h"
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/blkdev.h>
static int discard_extent(struct block_device *bdev, sector_t start,
sector_t len)
{
assert("intelfx-21", bdev != NULL);
return blkdev_issue_discard(bdev, start,
len, reiser4_ctx_gfp_mask_get(), 0);
}/*
* Return size of head padding of an extent on a lattice
* with step @ulen and offset @uoff.
* @start - the start offset of the extent.
*/
static int extent_get_headp(reiser4_block_nr start, int uoff, int ulen)
{
__u64 headp;
headp = ulen + start - uoff;
headp = do_div(headp, ulen);
return headp;
}/*
* Return size of tail padding of an extent on a lattice
* with step @ulen and offset @uoff.
* @end - the end offset of the extent.
*/
static int extent_get_tailp(reiser4_block_nr end, int uoff, int ulen)
{
__u64 tailp;
tailp = ulen + end - uoff;
tailp = do_div(tailp, ulen);
if (tailp)
tailp = ulen - tailp;
return tailp;
}static inline struct list_head *get_next_at(struct list_head *pos,
struct list_head *head)
{
assert("edward-1631", pos != NULL);
assert("edward-1632", head != NULL);
assert("edward-1633", pos != head);
return pos->next == head ? NULL : pos->next;
}static inline int check_free_blocks(const reiser4_block_nr start,
const reiser4_block_nr len)
{
return reiser4_check_blocks(&start, &len, 0);
}/* Make sure that extents are sorted and merged */
#if REISER4_DEBUG
static inline void check_blocknr_list_at(struct list_head *pos,
struct list_head *head)
{
struct list_head *next;
next = get_next_at(pos, head);
if (next == NULL)
return;
if (blocknr_list_entry_start(next) <=
blocknr_list_entry_start(pos) + blocknr_list_entry_len(pos))
warning("edward-1634",
"discard bad pair of extents: (%llu,%llu), (%llu,%llu)",
blocknr_list_entry_start(pos),
blocknr_list_entry_len(pos),
blocknr_list_entry_start(next),
blocknr_list_entry_len(next));
}#else
#define check_blocknr_list_at(pos, head) noop
#endif
/*
* discard_sorted_merged_extents() - scan the list of sorted and
* merged extents and check head and tail paddings of each
* extent in the working space map. Try to "glue" the nearby
* extents. Discard the (glued) extents with padded (or cut)
* head and tail.
*
* Pre-conditions: @head points to the list of sorted and
* merged extents.
*
* Local variables:
*
* d_uni - discard unit size (in blocks);
* d_off - discard alignment (in blocks);
*
* start - offset of the first block of the extent;
* len - length of the extent;
* end - offset of the first block beyond extent;
*
* headp - size of head padding of the extent;
* tailp - size of tail padding of the extent;
*
* astart - actual start to discard (offset of the head padding);
* alen - actual length to discard (length of glued aligned and padded extents). *
* Terminology in the comments:
*
* head - a part of extent at the beginning;
* tail - a part of extent at the end.
*/
static int discard_sorted_merged_extents(struct list_head *head)
{
int ret;
struct super_block *sb = reiser4_get_current_sb();
struct queue_limits *limits = &bdev_get_queue(sb->s_bdev)->limits;
int d_uni;
int d_off;
struct list_head *pos;
d_uni = limits->discard_granularity / sb->s_blocksize;
if (d_uni == 0)
d_uni = 1;
d_off = (bdev_discard_alignment(sb->s_bdev) / sb->s_blocksize) % d_uni;
for (pos = head->next; pos != head; pos = pos->next) {
int headp;
int tailp;
int headp_is_known_dirty = 0;
reiser4_block_nr start;
reiser4_block_nr len;
reiser4_block_nr end;
reiser4_block_nr astart; __s64 alen;
check_blocknr_list_at(pos, head);
start = blocknr_list_entry_start(pos);
len = blocknr_list_entry_len(pos);
/*
* Step I. Cut or pad the head of extent
*
* This extent wasn't glued
*/
headp = extent_get_headp(start, d_off, d_uni);
if (headp && !headp_is_known_dirty &&
check_free_blocks(start - headp, headp)) {
/*
* head padding is clean,
* pad the head
*/
astart = start - headp;
alen = len + headp;
}
else if (headp == 0) {
/*
* empty head padding
*/
assert("edward-1635", headp_is_known_dirty == 0);
astart = start;
alen = len;
} else {
/*
* head padding is not empty and dirty,
* cut the head
*/
headp_is_known_dirty = 0;
astart = start + (d_uni - headp);
alen = len - (d_uni - headp);
}
/*
* Step II. Try to glue all nearby extents to the tail
* Cut or pad the tail of the last extent.
*/
end = start + len;
tailp = extent_get_tailp(end, d_off, d_uni);
/*
* This "gluing" loop updates @pos, @end, @tailp, @alen
*/
while (1) {
struct list_head *next;
next = get_next_at(pos, head);
check_blocknr_list_at(next, head);
if (next && (end + tailp >= blocknr_list_entry_start(next))) {
/*
* try to glue the next extent
*/
reiser4_block_nr next_start;
reiser4_block_nr next_len;
next_start = blocknr_list_entry_start(next);
next_len = blocknr_list_entry_len(next);
if (check_free_blocks(end, next_start - end)) {
/*
* jump to the glued extent
*/
if (end + tailp < next_start + next_len) {
/*
* the glued extent doesn't
* fit into the tail padding,
* so update the last one
*/
tailp = extent_get_tailp(next_start + next_len,
d_off, d_uni);
alen += (next_start + next_len - end);
}
pos = next;
end = next_start + next_len;
/*
* try to glue more extents
*/
continue;
} else {
/*
* gluing failed, cut the tail
*/
if (end + tailp > next_start)
headp_is_known_dirty = 1;
alen -= (d_uni - tailp);
break;
}
} else {
/*
* nothing to glue:
* this is the last extent, or the next
* extent is too far. So just check the
* rest of tail padding
*/
if (tailp && check_free_blocks(end, tailp))
/*
* tail padding is clean,
* pad the tail
*/
alen += tailp;
else
/*
* empty or dirty tail padding,
* cut the tail
*/
alen -= (d_uni - tailp);
break;
}
}
/*
* Step III. Discard the result
*/
if (alen > 0) {
ret = discard_extent(sb->s_bdev,
astart * (sb->s_blocksize >> 9),
alen * (sb->s_blocksize >> 9));
if (ret)
return ret;
}
}
return 0;
}int discard_atom(txn_atom *atom)
{
int ret;
struct list_head discard_set;
if (!reiser4_is_set(reiser4_get_current_sb(), REISER4_DISCARD)) {
spin_unlock_atom(atom);
return 0;
}
assert("intelfx-28", atom != NULL);
if (list_empty(&atom->discard.delete_set) &&
list_empty(&atom->discard.aux_delete_set)) {
spin_unlock_atom(atom);
return 0;
}
/* Take the delete sets from the atom in order to release atom spinlock. */
blocknr_list_init(&discard_set);
blocknr_list_merge(&atom->discard.delete_set, &discard_set);
blocknr_list_merge(&atom->discard.aux_delete_set, &discard_set);
spin_unlock_atom(atom);
/* Sort the discard list, joining adjacent extents. */
blocknr_list_sort_and_join(&discard_set);
/*
* Perform actual dirty work
*/
ret = discard_sorted_merged_extents(&discard_set);
if (ret != 0)
return ret;
/*
* Let's do this again for any new extents in the atom's discard set
*/
return -E_REPEAT;
}/* Make Linus happy.
Local variables:
c-indentation-style: "K&R"
mode-name: "LC"
c-basic-offset: 8
tab-width: 8
fill-column: 120
scroll-step: 1
End:
*/
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 41 lines · Edward Shishkin
Quoted 39 lines · Ivan Shapovalov
Quoted 29 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 5 lines
Quoted 2 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
Quoted 7 lines
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.
P.S. I tested it, but not enough.Hm. I'm probably a dumbass, but...
Quoted 8 lines
Quoted 1 line
I don't see where the [start; start+len) region is checked for being free.
check_free_blocks()is called for this purpose.Firstly when checking head padding. Secondly in the gluing loop (to glue 2 extents in particular means to make sure that region between them is free). Finally we check if the tail padding is free.
There are three calls to check_free_blocks():
line 197, check_free_blocks(start - headp, headp)
This checks first extent's head padding.
line 247, check_free_blocks(end, next_start - end)
This checks blocks between end of first extent and start of second extent (including possible tail padding of first extent and possible head padding of second extent).
line 284, check_free_blocks(end, tailp)
This checks first extent's tail padding.
Nothing seems to call at least check_free_blocks(begin, end)...
BTW, what's the purpose of headp_is_known_dirty? All uses of this variable can be compile-time resolved to 0. It is never read after assigned 1.
Quoted 10 lines
Quoted 6 lines
Also, btw, do we need to cut the head (lines 155-163 of the patch) if headp is empty? It seems that it would reduce extent by one whole erase unit without any justification.
Yes, this is definitely a leak of not discarded erase units. Is the attached version better?
Yes.. and lines 290-295, seems that tail padding handling has the same problem. If tailp == 0 (i. e. division remainder is 0 so that end is already aligned), alen is reduced by d_uni.
Quoted 2 lines
Edward.
Signature · 1 line
Ivan Shapovalov / intelfx /
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 57 lines · Ivan Shapovalov
Quoted 39 lines · Edward Shishkin
Quoted 38 lines · Ivan Shapovalov
Quoted 27 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 22 lines
Quoted 5 lines
Quoted 3 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 5 lines
Quoted 2 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Quoted 8 lines
Quoted 1 line
Yes, it's costly... but I don't see any other ways to do the task efficiently.
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.
P.S. I tested it, but not enough.Hm. I'm probably a dumbass, but...
Quoted 7 lines
Quoted 1 line
I don't see where the [start; start+len) region is checked for being free.
check_free_blocks()is called for this purpose.Firstly when checking head padding. Secondly in the gluing loop (to glue 2 extents in particular means to make sure that region between them is free). Finally we check if the tail padding is free.
There are three calls to
check_free_blocks():line 197,
check_free_blocks(start - headp, headp)
This checks first extent's head padding.line 247,
check_free_blocks(end, next_start - end)
This checks blocks between end of first extent and start of second extent (including possible tail padding of first extent and possible head padding of second extent).
Quoted 4 lines
line 284,
check_free_blocks(end, tailp)
This checks first extent's tail padding.Nothing seems to call at least
check_free_blocks(begin, end)...
Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...
Why not to delay the actual deallocation (in the working bitmap)? Anyway, in the situations of disk space pressure (on the first "soft ENOSPC") everyone waits for commit-everything completion. Let's think in this direction...
Quoted 2 lines
BTW, what's the purpose of
headp_is_known_dirty?
To avoid unneeded checks.
(end + tailp > next_start) means that the head padding of the next extent includes the region [end, next_start), which was found dirty (when trying to glue this next extent).
Quoted 2 lines
All uses of this variable
can be compile-time resolved to 0. It is never read after assigned 1.
Yup. Its declaration with the first assignment are at wrong place. It should be above (near the @pos). I definitely needed to work more on this function.
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Also, btw, do we need to cut the head (lines 155-163 of the patch) if headp is empty? It seems that it would reduce extent by one whole erase unit without any justification.
Yes, this is definitely a leak of not discarded erase units. Is the attached version better?
Yes.. and lines 290-295, seems that tail padding handling has the same problem. If tailp == 0 (i. e. division remainder is 0 so that end is already aligned),
OK, will be fixed in the same way.
Thanks,
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 70 lines · Edward Shishkin
Quoted 57 lines · Ivan Shapovalov
Quoted 39 lines · Edward Shishkin
Quoted 38 lines · Ivan Shapovalov
Quoted 27 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 22 lines
Quoted 5 lines
Quoted 3 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 5 lines
Quoted 2 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Quoted 8 lines
Quoted 1 line
Yes, it's costly... but I don't see any other ways to do the task efficiently.
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.
P.S. I tested it, but not enough.Hm. I'm probably a dumbass, but...
Quoted 7 lines
Quoted 1 line
I don't see where the [start; start+len) region is checked for being free.
check_free_blocks()is called for this purpose.Firstly when checking head padding. Secondly in the gluing loop (to glue 2 extents in particular means to make sure that region between them is free). Finally we check if the tail padding is free.
There are three calls to
check_free_blocks():line 197,
check_free_blocks(start - headp, headp)
This checks first extent's head padding.line 247,
check_free_blocks(end, next_start - end)
This checks blocks between end of first extent and start of second extent (including possible tail padding of first extent and possible head padding of second extent).Quoted 4 lines
line 284,
check_free_blocks(end, tailp)
This checks first extent's tail padding.Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty
in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...
Quoted 5 lines
Why not to delay the actual deallocation (in the working bitmap)? Anyway, in the situations of disk space pressure (on the first "soft ENOSPC")
everyone waits for commit-everything completion. Let's think in this direction...
That's a good idea, actually. Let's outline what is needed for this:
- move reiser4_post_commit_hook() after the call to discard;
This will also move it outside of reiser4_write_logs(), after reiser4_post_write_back_hook() and various immediate deallocations done by the journal code. I suppose this is OK for we're under commit mutex anyway.
- defer journal's immediate deallocations until discard.
This is more interesting. Inside of the journal code, blocks are deallocated in four places:
* dealloc_tx_list()
* dealloc_wmap() -> dealloc_wmap_actor()
* add_region_to_wmap() /* in error path */
* alloc_tx() /* seems like in error path, len == 0 in case of normal exit */
That is, blocks are deallocated after all meaningful work and so relative order of these deallocations seems to not matter.
Given that point 1 is done, i. e. delete_set is applied to WORKING BITMAP after reiser4_write_logs(), we can simply make these deallocations deferred (BA_DEFER flag). This way, we also get rid of aux_delete_set.
The only thing to check is deallocation attributes. All journal's deallocations are done with target_stage == BLOCK_NOT_COUNTED. This happily coincides with what's done in apply_dset(), so no problems here.
Is this correct?
Thanks,
Signature · 1 line
Ivan Shapovalov / intelfx /
Quoted 36 lines
Quoted 4 lines
BTW, what's the purpose of
headp_is_known_dirty?To avoid unneeded checks.
(end + tailp >
next_start) means that the head padding of the next extent includes the region [end,next_start), which was found dirty (when trying to glue this next extent).Quoted 2 lines
All uses of this variable
can be compile-time resolved to 0. It is never read after assigned 1.Yup. Its declaration with the first assignment are at wrong place. It should be above (near the @pos). I definitely needed to work more on this function.
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
Also, btw, do we need to cut the head (lines 155-163 of the patch) if headp is empty? It seems that it would reduce extent by one whole erase unit without any justification.
Yes, this is definitely a leak of not discarded erase units. Is the attached version better?
Yes.. and lines 290-295, seems that tail padding handling has the same problem. If tailp == 0 (i. e. division remainder is 0 so that end is already aligned),
OK, will be fixed in the same way.
Thanks,
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 67 lines · Ivan Shapovalov
Quoted 66 lines · Edward Shishkin
Quoted 56 lines · Ivan Shapovalov
Quoted 37 lines · Edward Shishkin
Quoted 36 lines · Ivan Shapovalov
Quoted 35 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
Quoted 2 lines · Edward Shishkin
On 06/22/2014 12:48 PM, Ivan Shapovalov wrote:
[...][...]
Quoted 16 lines
Quoted 5 lines
Quoted 3 lines
+ * - if a single extent is smaller than the erase unit, then this particular
+ * extent won't be discarded even if it is surrounded by enough free blocks
+ * to constitute a whole erase unit;Why not to discard the aligned and padded extent, which coincides with the whole erase unit?
With a number of whole erase units.
Quoted 5 lines
Quoted 2 lines
+ * - we won't be able to merge small adjacent extents forming an extent long
+ * enough to be discarded.At this point we have already sorted and merged everything.
So may be it makes sense just to check the head and tail of every resulted extent and discard the aligned and padded one?"Head and tail" is not sufficient. We may check the whole extent with a single bitmap request, but such algorithm will be very inefficient: it will miss many possibilities for discarding.
Quoted 7 lines
Consider many-block extent, from which one block has been allocated again. In this case we miss (all-1) blocks to be discarded (if granularity = 1 block).
Quoted 3 lines
Please, consider such possibility. Iterating over erase units in
discard_extent()
looks suboptimal.Yes, it's costly... but I don't see any other ways to do the task efficiently.
How about this function? (the attached patch is against v6-series). Total number of bitmap checks is in [N+1, 2N], where N is number of extents in the list. At the same time we don't leave any non-discarded "garbage"...
Edward.
P.S. I tested it, but not enough.Quoted 8 lines
Quoted 3 lines
Hm. I'm probably a dumbass, but...
I don't see where the [start; start+len) region is checked for being free.
check_free_blocks()is called for this purpose.Firstly when checking head padding. Secondly in the gluing loop (to glue 2 extents in particular means to make sure that region between them is free). Finally we check if the tail padding is free.
There are three calls to
check_free_blocks():line 197,
check_free_blocks(start - headp, headp)
This checks first extent's head padding.line 247,
check_free_blocks(end, next_start - end)
This checks blocks between end of first extent and start of second extent (including possible tail padding of first extent and possible head padding of second extent).Quoted 4 lines
line 284,
check_free_blocks(end, tailp)
This checks first extent's tail padding.Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty
in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...
Quoted 8 lines
Quoted 5 lines
Why not to delay the actual deallocation (in the working bitmap)? Anyway, in the situations of disk space pressure (on the first "soft ENOSPC")
everyone waits for commit-everything completion. Let's think in this direction...That's a good idea, actually. Let's outline what is needed for this:
- move
reiser4_post_commit_hook()after the call to discard;
To be precise, not the post_commit_hook itself, only its current content.
Those hooks are undocumented, but I think that
- pre_commit_hook is something that should be called before journal writes;
- post_commit_hook is something that should be called after journal writes completion and before overwrites;
- post_write_back_hook is something that should be called after issuing the overwrites.
I suggest to use the post_write_back_hook for discard with the following cleaning working bitmap. Move this hook to suitable place (make sure it is after write_tx_back() and journal's "immediate" dealocations).
Quoted 6 lines
This will also move it outside of
reiser4_write_logs(), afterreiser4_post_write_back_hook()and various immediate deallocations done by the journal code. I suppose this is OK for we're under commit mutex anyway.- defer journal's immediate deallocations until discard.
Quoted 8 lines
This is more interesting. Inside of the journal code, blocks are deallocated in four places:
*dealloc_tx_list()
*dealloc_wmap()->dealloc_wmap_actor()
*add_region_to_wmap()/* in error path */
*alloc_tx()/* seems like in error path, len == 0 in case of normal exit */That is, blocks are deallocated after all meaningful work
We want those 4 deallocations to be after pre_commit_hook. In this case they won't affect commit bitmap if we make them deferred.
Quoted 6 lines
and so relative
order of these deallocations seems to not matter.Given that point 1 is done, i. e.
delete_setis applied to WORKING BITMAP afterreiser4_write_logs(), we can simply make these deallocations deferred (BA_DEFERflag). This way, we also get rid ofaux_delete_set.
Yes, make reiser4_block_alloc() jump to "defer" branch if discard mode is on.
Quoted 5 lines
The only thing to check is deallocation attributes. All journal's deallocations are done with
target_stage==BLOCK_NOT_COUNTED. This happily coincides with what's done inapply_dset(), so no problems here.Is this correct?
Looks OK.
Thanks,
Edward.
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 3 lines · Edward Shishkin
Quoted 1 line · Ivan Shapovalov
On Monday 14 July 2014 at 03:56:43, Edward Shishkin wrote:
[...]
Quoted 49 lines
Quoted 9 lines
Quoted 6 lines
Why not to delay the actual deallocation (in the working bitmap)? Anyway, in the situations of disk space pressure (on the first "soft ENOSPC")
everyone waits for commit-everything completion. Let's think in this direction...That's a good idea, actually. Let's outline what is needed for this:
- move
reiser4_post_commit_hook()after the call to discard;To be precise, not the
post_commit_hookitself, only its current content.Those hooks are undocumented, but I think that
-pre_commit_hookis something that should be called before journal writes;
-post_commit_hookis something that should be called after journal writes completion and before overwrites;
-post_write_back_hookis something that should be called after issuing the overwrites.I suggest to use the
post_write_back_hookfor discard with the following cleaning working bitmap. Move this hook to suitable place (make sure it is afterwrite_tx_back()and journal's "immediate" dealocations).Quoted 6 lines
This will also move it outside of
reiser4_write_logs(), afterreiser4_post_write_back_hook()and various immediate deallocations done by the journal code. I suppose this is OK for we're under commit mutex anyway.- defer journal's immediate deallocations until discard.
Quoted 8 lines
This is more interesting. Inside of the journal code, blocks are deallocated in four places:
*dealloc_tx_list()
*dealloc_wmap()->dealloc_wmap_actor()
*add_region_to_wmap()/* in error path */
*alloc_tx()/* seems like in error path, len == 0 in case of normal exit */That is, blocks are deallocated after all meaningful work
We want those 4 deallocations to be after
pre_commit_hook. In this case they won't affect commit bitmap if we make them deferred.Quoted 3 lines
and so relative
order of these deallocations seems to not matter.
Quoted 6 lines
Quoted 3 lines
Given that point 1 is done, i. e.
delete_setis applied to WORKING BITMAP afterreiser4_write_logs(), we can simply make these deallocations deferred (BA_DEFERflag). This way, we also get rid ofaux_delete_set.Yes, make
reiser4_block_alloc()jump to "defer" branch if discard mode
^reiser4_block_alloc^reiser4_dealloc_blocks
Quoted 13 lines
is on.
Quoted 5 lines
The only thing to check is deallocation attributes. All journal's deallocations are done with
target_stage==BLOCK_NOT_COUNTED. This happily coincides with what's done inapply_dset(), so no problems here.Is this correct?
Looks OK.
Thanks,
Edward.
cover reiser4: discard before dealloc: first approximation.
In reply to Edward ShishkinThis needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
BTW, have you dropped the case with erase unit size < block size? This is probably OK, but configurations with nonzero alignments are then broken. Not worth handling these, I think, but nevertheless a warning could be useful ;)
Ivan Shapovalov (2):
reiser4: discard support: perform discards and deallocations after writing logs.
reiser4: discard support: proof-of-concept for "discard before dealloc".
fs/reiser4/block_alloc.c | 48 +++++++++++++++++++------------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 35 ---------------------------- fs/reiser4/txnmgr.h | 13 ++--------- fs/reiser4/wander.c | 3 ++- 6 files changed, 73 insertions(+), 90 deletions(-)
Signature · 1 line
2.0.1
PATCH 1/2 reiser4: discard support: perform discards and deallocations after writing logs.
reiser4_post_write_back_hook() is now used for both of these things. The call is moved after journalling code is done with deallocations.
--- fs/reiser4/block_alloc.c | 24 +++++++++++++++++++----- fs/reiser4/txnmgr.c | 11 ----------- fs/reiser4/wander.c | 3 ++- 3 files changed, 21 insertions(+), 17 deletions(-)
fs/reiser4/block_alloc.c +19 -5
@@ -1136,15 +1136,13 @@ apply_dset(txn_atom * atom UNUSED_ARG, const reiser4_block_nr * a,void reiser4_post_commit_hook (void ) { +#ifdef REISER4_DEBUG txn_atom *atom; atom =get_current_atom_locked ();assert ("zam-452" , atom->stage ==ASTAGE_POST_COMMIT );spin_unlock_atom (atom); - -/* do the block deallocation which was deferred -until commit is done */ -atom_dset_deferred_apply (atom, apply_dset,NULL ,0 ); +#endif assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_commit_hook ();
@@ -1152,8 +1150,24 @@ void reiser4_post_commit_hook(void)void reiser4_post_write_back_hook (void ) { -assert ("zam-504" ,get_current_super_private () !=NULL ); +txn_atom *atom; +int ret; +/* process and issue discard requests */ +do { + atom =get_current_atom_locked (); + ret =discard_atom (*atom); + }while (ret == -E_REPEAT ); + +if (ret) { +warning ("intelfx-8" ,"discard atom failed (%ld)" , ret); + } + +/* do the block deallocation which was deferred +until commit is done */ +atom_dset_deferred_apply (atom, apply_dset,NULL ,0 ); + +assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_write_back_hook (); }
fs/reiser4/txnmgr.c +0 -11
@@ -1089,17 +1089,6 @@ static int commit_current_atom(long *nr_submitted, txn_atom ** atom)if (ret <0 )reiser4_panic ("zam-597" ,"write log failed (%ld)\n" , ret); -/* process and issue discard requests */ -do { -spin_lock_atom (*atom); - ret =discard_atom (*atom); - }while (ret == -E_REPEAT ); - -if (ret) { -warning ("intelfx-8" ,"discard atom failed (%ld)" , ret); - ret =0 ;/* the discard is optional, don't fail the commit */ - } -/* The atom->ovrwr_nodes list is processed under commit mutex held because of bitmap nodes which are captured by special way in reiser4_pre_commit_hook_bitmap(), that way does not include
fs/reiser4/wander.c +2 -1
@@ -1252,7 +1252,6 @@ int reiser4_write_logs(long *nr_submitted)reiser4_post_commit_hook (); ret =write_tx_back (&ch); -reiser4_post_write_back_hook (); up_and_ret:if (ret) {
@@ -1265,6 +1264,8 @@ int reiser4_write_logs(long *nr_submitted)dealloc_tx_list (&ch);dealloc_wmap (&ch); +reiser4_post_write_back_hook (); +put_overwrite_set (&ch);done_commit_handle (&ch);
Signature · 1 line
2.0.1
PATCH 2/2 reiser4: discard support: proof-of-concept for "discard before dealloc".
In reply to Ivan ShapovalovThis is INCOMPLETE and needs a modified discard_extent() because blocks inside of original extents are always allocated but allowed for discarding.
--- fs/reiser4/block_alloc.c | 28 +++++----------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 24 ------------------- fs/reiser4/txnmgr.h | 13 ++--------- 5 files changed, 54 insertions(+), 75 deletions(-)
fs/reiser4/block_alloc.c +6 -22
@@ -1007,7 +1007,8 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_reiser4_super (sbinfo); } -if (flags &BA_DEFER ) { +if ((flags &BA_DEFER ) || +reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {/* store deleted block numbers in the atom's deferred delete set for further actual deletion */ do {
@@ -1028,25 +1029,6 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_atom (atom); }else { -/* store deleted block numbers in the atom's immediate delete set -for further processing */ -do { - atom =get_current_atom_locked (); -assert ("intelfx-51" , atom !=NULL ); - - ret =atom_dset_immediate_add_extent (atom, &new_entry, start, len); - -if (ret == -ENOMEM ) -return ret; - -/* This loop might spin at most two times */ - }while (ret == -E_REPEAT ); - -assert ("intelfx-52" , ret ==0 ); -assert ("intelfx-53" , atom !=NULL ); - -spin_unlock_atom (atom); -assert ("zam-425" ,get_current_super_private () !=NULL );sa_dealloc_blocks (reiser4_get_space_allocator (ctx->super), *start, *len);
@@ -1150,13 +1132,15 @@ void reiser4_post_commit_hook(void)void reiser4_post_write_back_hook (void ) { +struct list_head discard_tmp;txn_atom *atom;int ret;/* process and issue discard requests */ +blocknr_list_init (&discard_tmp);do { atom =get_current_atom_locked (); - ret =discard_atom (*atom); + ret =discard_atom (*atom, &discard_tmp); }while (ret == -E_REPEAT );if (ret) {
@@ -1165,7 +1149,7 @@ void reiser4_post_write_back_hook(void)/* do the block deallocation which was deferred until commit is done */ -atom_dset_deferred_apply (atom, apply_dset,NULL ,0 ); +atom_dset_deferred_apply (atom, apply_dset,NULL ,1 );assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_write_back_hook ();
fs/reiser4/discard.c +43 -17
97 lines not on this page · raw message
fs/reiser4/discard.h +3 -1
@@ -14,8 +14,10 @@* if discard is enabled. In this case the delete sets are cleared. * * @atom should be locked on entry and is unlocked on exit. +* @processed_set keeps state between invocations in -E_REPEAT pattern; +* must be initialized with blocknr_list_init(). */ -extern int discard_atom (txn_atom *atom); +extern int discard_atom (txn_atom *atom,struct list_head *processed_set);/* __FS_REISER4_DISCARD_H__ */ #endif
fs/reiser4/txnmgr.c +0 -24
@@ -3081,7 +3081,6 @@ void atom_dset_init(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_init (&atom->discard.delete_set); -blocknr_list_init (&atom->discard.aux_delete_set); }else {blocknr_set_init (&atom->nodiscard.delete_set); }
@@ -3091,7 +3090,6 @@ void atom_dset_destroy(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_destroy (&atom->discard.delete_set); -blocknr_list_destroy (&atom->discard.aux_delete_set); }else {blocknr_set_destroy (&atom->nodiscard.delete_set); }
@@ -3101,7 +3099,6 @@ void atom_dset_merge(txn_atom *from, txn_atom *to) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_merge (&from->discard.delete_set, &to->discard.delete_set); -blocknr_list_merge (&from->discard.aux_delete_set, &to->discard.aux_delete_set); }else {blocknr_set_merge (&from->nodiscard.delete_set, &to->nodiscard.delete_set); }
@@ -3155,27 +3152,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom,return ret; } -extern int atom_dset_immediate_add_extent (txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len) -{ -int ret; - -if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) { - ret =blocknr_list_add_extent (atom, - &atom->discard.aux_delete_set, - (blocknr_list_entry **)new_entry, - start, - len); - }else { -/* no-op */ - ret =0 ; - } - -return ret; -} -/* * Local variables: * c-indentation-style: "K&R"
fs/reiser4/txnmgr.h +2 -11
@@ -259,10 +259,6 @@ struct txn_atom {/* The atom's delete set. It collects block numbers which were deallocated with BA_DEFER, i. e. of ordinary nodes. */ struct list_head delete_set; - -/* The atom's auxiliary delete set. It collects block numbers -which were deallocated without BA_DEFER, i. e. immediately. */ -struct list_head aux_delete_set; } discard; };
@@ -527,9 +523,8 @@ extern int blocknr_list_iterator(txn_atom *atom,/* These are wrappers for accessing and modifying atom's delete lists, depending on whether discard is enabled or not. -If it is enabled. both deferred and immediate delete lists are maintained, -and (less memory efficient) blocknr_lists are used for storage. Otherwise, only -deferred delete list is maintained and blocknr_set is used for its storage. */ +If it is enabled, (less memory efficient) blocknr_list is used for delete +list storage. Otherwise, blocknr_set is used for this purpose. */ extern void atom_dset_init (txn_atom *atom);extern void atom_dset_destroy (txn_atom *atom);extern void atom_dset_merge (txn_atom *from,txn_atom *to);
@@ -541,10 +536,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom,void **new_entry, const reiser4_block_nr *start, const reiser4_block_nr *len); -extern int atom_dset_immediate_add_extent (txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len);/* flush code takes care about how to fuse flush queues */ extern void flush_init_atom (txn_atom * atom);
Signature · 1 line
2.0.1
Re: [veryRFC] [PATCH 0/2] reiser4: discard before dealloc: first approximation.
In reply to Ivan ShapovalovQuoted 11 lines · Ivan Shapovalov
This needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
BTW, have you dropped the case with erase unit size < block size? This is probably OK, but configurations with nonzero alignments are then broken. Not worth handling these, I think, but nevertheless a warning could be useful ;)
Ivan Shapovalov (2):
reiser4: discard support: perform discards and deallocations after writing logs.
reiser4: discard support: proof-of-concept for "discard before dealloc".
Quoted 7 lines
fs/reiser4/block_alloc.c | 48 +++++++++++++++++++------------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 35 ---------------------------- fs/reiser4/txnmgr.h | 13 ++--------- fs/reiser4/wander.c | 3 ++- 6 files changed, 73 insertions(+), 90 deletions(-)
...and yes, these patches should be considered nothing but a payload for testing whatever you use for systematic full-system backups :)
Signature · 1 line
Ivan Shapovalov / intelfx /
Re: [veryRFC] [PATCH 0/2] reiser4: discard before dealloc: first approximation.
In reply to Ivan ShapovalovQuoted 2 lines · Ivan Shapovalov
This needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
OK, I'll try to finish it in weekends..
Quoted 1 line
BTW, have you dropped the case with erase unit size < block size?
In my version all erase units are supported except ones which are not a power of 2. We can support all erase units without exceptions, if needed.
Quoted 2 lines
This is
probably OK, but configurations with nonzero alignments are then broken.
I support alignments with (bdev_discard_alignment % sb->s_blocksize == 0) We can support all alignments without exceptions, but it will lead to complications in discard_sorted_extents().
Quoted 2 lines
Not
worth handling these, I think, but nevertheless a warning could be useful ;)
Agreed. It is important.
Thanks!
Edward.
Quoted 13 lines
Ivan Shapovalov (2):
reiser4: discard support: perform discards and deallocations after writing logs.
reiser4: discard support: proof-of-concept for "discard before dealloc".fs/reiser4/block_alloc.c | 48 +++++++++++++++++++------------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 35 ---------------------------- fs/reiser4/txnmgr.h | 13 ++--------- fs/reiser4/wander.c | 3 ++- 6 files changed, 73 insertions(+), 90 deletions(-)
Re: [veryRFC] [PATCH 0/2] reiser4: discard before dealloc: first approximation.
Quoted 8 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
This needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
OK, I'll try to finish it in weekends..
Quoted 6 lines
Quoted 1 line
BTW, have you dropped the case with erase unit size < block size?
In my version all erase units are supported except ones which are not a power of 2. We can support all erase units without exceptions, if needed.
I mean, when erase unit size < block size, erase unit size is forced to be exactly one block. Again, this is OK, but in this case any alignment (by definition less than one block then) will be dropped and represented as zero, and _this_ deserves a warning :)
// btw, as you probably guess, these two patches are completely untested.
Thanks,
Signature · 1 line
Ivan Shapovalov / intelfx /
Quoted 35 lines
Quoted 4 lines
This is
probably OK, but configurations with nonzero alignments are then broken.I support alignments with (
bdev_discard_alignment%sb->s_blocksize== 0) We can support all alignments without exceptions, but it will lead to complications
indiscard_sorted_extents().Quoted 2 lines
Not
worth handling these, I think, but nevertheless a warning could be useful ;)Agreed. It is important.
Thanks!
Edward.Quoted 13 lines
Ivan Shapovalov (2):
reiser4: discard support: perform discards and deallocations after writing logs.
reiser4: discard support: proof-of-concept for "discard before dealloc".fs/reiser4/block_alloc.c | 48 +++++++++++++++++++------------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 35 ---------------------------- fs/reiser4/txnmgr.h | 13 ++--------- fs/reiser4/wander.c | 3 ++- 6 files changed, 73 insertions(+), 90 deletions(-)
Re: [veryRFC] [PATCH 0/2] reiser4: discard before dealloc: first approximation.
Quoted 10 lines · Ivan Shapovalov
Quoted 9 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
This needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
OK, I'll try to finish it in weekends..
Quoted 1 line
BTW, have you dropped the case with erase unit size < block size?
Quoted 7 lines
Quoted 3 lines
In my version all erase units are supported except ones which are not a power of 2. We can support all erase units without exceptions, if needed.
I mean, when erase unit size < block size, erase unit size is forced to be exactly one block. Again, this is OK, but in this case any alignment (by definition less than one block then) will be dropped and represented as zero, and _this_ deserves a warning :)
The case of alignment % block_size != 0 deserves to disable discard support, because in this case all this science with heads and tails simply doesn't work.
Quoted 4 lines
// btw, as you probably guess, these two patches are completely untested.
Thanks,
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
In reply to Edward ShishkinQuoted 3 lines · Edward Shishkin
Quoted 1 line · Ivan Shapovalov
[...]
Quoted 7 lines
Quoted 2 lines
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...
False alarm, actually..
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing the commit_mutex _after_ our discard. Everything is isolated.. For the same reason we don't care if someone allocate blocks in head and tail paddings before issuing our padded discard extents. We only need to make sure that they were clean at _our_ commit session.
Anyway, let's use delayed deallocation. I like it better than aux_delete_set. After all, we can roll everything back at every moment, if any problems..
Edward.
Re: [veryRFC] [PATCH 2/2] reiser4: discard support: proof-of-concept for "discard before dealloc".
In reply to Ivan ShapovalovQuoted 57 lines · Ivan Shapovalov
This is INCOMPLETE and needs a modified
discard_extent()because blocks inside of original extents are always allocated but allowed for discarding.Signed-off-by Ivan Shapovalov <[email protected]>--- fs/reiser4/block_alloc.c | 28 +++++----------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 24 ------------------- fs/reiser4/txnmgr.h | 13 ++--------- 5 files changed, 54 insertions(+), 75 deletions(-)fs/reiser4/block_alloc.c +3
-20@@ -1007,7 +1007,8 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_reiser4_super (sbinfo); } -if (flags &BA_DEFER ) { +if ((flags &BA_DEFER ) || +reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {/* store deleted block numbers in the atom's deferred delete set for further actual deletion */ do {@@ -1028,25 +1029,6 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_atom (atom); }else { -/* store deleted block numbers in the atom's immediate delete set -for further processing */ -do { - atom =get_current_atom_locked (); -assert ("intelfx-51" , atom !=NULL ); - - ret =atom_dset_immediate_add_extent (atom, &new_entry, start, len); - -if (ret == -ENOMEM ) -return ret; - -/* This loop might spin at most two times */ - }while (ret == -E_REPEAT ); - -assert ("intelfx-52" , ret ==0 ); -assert ("intelfx-53" , atom !=NULL ); - -spin_unlock_atom (atom); -assert ("zam-425" ,get_current_super_private () !=NULL );sa_dealloc_blocks (reiser4_get_space_allocator (ctx->super), *start, *len);@@ -1150,13 +1132,15 @@ void reiser4_post_commit_hook(void)void reiser4_post_write_back_hook (void ) { +struct list_head discard_tmp;
fs/reiser4/block_alloc.c void reiser4_post_commit_hook(void) · line 1144
Quoted 10 lines
fs/reiser4/block_alloc.c +2
-1txn_atom *atom;int ret;/* process and issue discard requests */ +blocknr_list_init (&discard_tmp);do { atom =get_current_atom_locked (); - ret =discard_atom (*atom); + ret =discard_atom (*atom, &discard_tmp); }while (ret == -E_REPEAT );
This is a leak of disk space on error paths:
if (ret != 0 && ret != -E_REPEAT), then delete_set is empty, or incomplete at this point.
Quoted 226 lines
fs/reiser4/block_alloc.c +1
-1if (ret) {@@ -1165,7 +1149,7 @@ void reiser4_post_write_back_hook(void)/* do the block deallocation which was deferred until commit is done */ -atom_dset_deferred_apply (atom, apply_dset,NULL ,0 ); +atom_dset_deferred_apply (atom, apply_dset,NULL ,1 );assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_write_back_hook ();fs/reiser4/discard.c +43
-17@@ -33,24 +33,42 @@* MECHANISM: * * During the transaction deallocated extents are recorded in atom's delete -* sets. There are two delete sets, because data in one of them (delete_set) is -* also used by other parts of reiser4. The second delete set (aux_delete_set) -* complements the first one and is maintained only when discard is enabled. +* set. In reiser4, there are two methods to deallocate a block: +* 1. deferred deallocation, enabled by BA_DEFER flag to reiser4_dealloc_block(). +* In this mode, blocks are stored to delete set instead of being marked free +* immediately. After committing the transaction, the delete set is "applied" +* by the block allocator and all these blocks are marked free in memory +* (see reiser4_post_commit_hook()). +* Space management plugins also read the delete set to update on-disk +* allocation records (see reiser4_pre_commit_hook()). +* 2. immediate deallocation (the opposite). +* In this mode, blocks are marked free immediately. This is used by the +* journal subsystem to manage space used by the journal records, so these +* allocations are not visible to the space management plugins and never hit +* the disk. * -* Together these sets constitute "the discard set" -- blocks that have to be -* considered for discarding. On atom commit we will generate a minimal -* superset of the discard set, comprised of whole erase units. +* When discard is enabled, all immediate deallocations become deferred. This +* is OK because journal's allocations happen after reiser4_pre_commit_hook() +* where the on-disk space allocation records are updated. So, in this mode +* the atom's delete set becomes "the discard set" -- list of blocks that have +* to be considered for discarding. +* +* On atom commit we will generate a minimal superset of the discard set, +* comprised of whole erase units. +* +* Discarding is performed before reiser4_post_commit_hook(), hence all extents +* in the discard set are still marked as allocated and cannot contain any data. +* Thus we can avoid any checks for blocks directly present in the discard set. +* +* However, we pad each extent from both sides to erase unit boundaries, and +* these paddings still have to be checked if they fall outside of initial +* extent (may not happen if block size > erase unit size). * * So, at commit time the following actions take place: * - delete sets are merged to form the discard set; * - elements of the discard set are sorted; * - the discard set is iterated, joining any adjacent extents; -* - each of resulting extents is "covered" by erase units: -* - its start is rounded down to the closest erase unit boundary; -* - starting from this block, extents of erase unit length are created -* until the original extent is fully covered; -* - the calculated erase units are checked to be fully deallocated; -* - remaining (valid) erase units are then passed to blkdev_issue_discard(). +* - <TODO> */ #include "discard.h" @@ -167,7 +185,7 @@ static int discard_extent(txn_atom *atom UNUSED_ARG,return 0 ; } -int discard_atom (txn_atom *atom) +int discard_atom (txn_atom *atom,struct list_head *processed_set) {int ret;struct list_head discard_set;@@ -178,9 +196,14 @@ int discard_atom(txn_atom *atom) }assert ("intelfx-28" , atom !=NULL ); +assert ("intelfx-59" , processed_entries !=NULL ); -if (list_empty (&atom->discard.delete_set) && -list_empty (&atom->discard.aux_delete_set)) { +if (list_empty (&atom->discard.delete_set)) { +/* +* Nothing left to discard. Move all processed entries back to atom +* for reiser4_post_commit_hook(). +*/ +blocknr_list_merge (processed_set, &atom->discard.delete_set);spin_unlock_atom (atom);return 0 ; }@@ -188,14 +211,17 @@ int discard_atom(txn_atom *atom)/* Take the delete sets from the atom in order to release atom spinlock. */ blocknr_list_init (&discard_set);blocknr_list_merge (&atom->discard.delete_set, &discard_set); -blocknr_list_merge (&atom->discard.aux_delete_set, &discard_set);spin_unlock_atom (atom);/* Sort the discard list, joining adjacent and overlapping extents. */ blocknr_list_sort_and_join (&discard_set);/* Perform actual dirty work. */ - ret =blocknr_list_iterator (NULL , &discard_set, &discard_extent,NULL ,1 ); + ret =blocknr_list_iterator (NULL , &discard_set, &discard_extent,NULL ,0 ); + +/* Add processed extents to the temporary list. */ +blocknr_list_merge (&discard_set, processed_set); +if (ret !=0 ) {return ret; }fs/reiser4/discard.h +3
-1@@ -14,8 +14,10 @@* if discard is enabled. In this case the delete sets are cleared. * * @atom should be locked on entry and is unlocked on exit. +* @processed_set keeps state between invocations in -E_REPEAT pattern; +* must be initialized with blocknr_list_init(). */ -extern int discard_atom (txn_atom *atom); +extern int discard_atom (txn_atom *atom,struct list_head *processed_set);/* __FS_REISER4_DISCARD_H__ */ #endif fs/reiser4/txnmgr.c +0
-24@@ -3081,7 +3081,6 @@ void atom_dset_init(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_init (&atom->discard.delete_set); -blocknr_list_init (&atom->discard.aux_delete_set); }else {blocknr_set_init (&atom->nodiscard.delete_set); }@@ -3091,7 +3090,6 @@ void atom_dset_destroy(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_destroy (&atom->discard.delete_set); -blocknr_list_destroy (&atom->discard.aux_delete_set); }else {blocknr_set_destroy (&atom->nodiscard.delete_set); }@@ -3101,7 +3099,6 @@ void atom_dset_merge(txn_atom *from, txn_atom *to) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_merge (&from->discard.delete_set, &to->discard.delete_set); -blocknr_list_merge (&from->discard.aux_delete_set, &to->discard.aux_delete_set); }else {blocknr_set_merge (&from->nodiscard.delete_set, &to->nodiscard.delete_set); }@@ -3155,27 +3152,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom,return ret; } -extern int atom_dset_immediate_add_extent (txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len) -{ -int ret; - -if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) { - ret =blocknr_list_add_extent (atom, - &atom->discard.aux_delete_set, - (blocknr_list_entry **)new_entry, - start, - len); - }else { -/* no-op */ - ret =0 ; - } - -return ret; -} -/* * Local variables: * c-indentation-style: "K&R" fs/reiser4/txnmgr.h +2
-11@@ -259,10 +259,6 @@ struct txn_atom {/* The atom's delete set. It collects block numbers which were deallocated with BA_DEFER, i. e. of ordinary nodes. */ struct list_head delete_set; - -/* The atom's auxiliary delete set. It collects block numbers -which were deallocated without BA_DEFER, i. e. immediately. */ -struct list_head aux_delete_set; } discard; };@@ -527,9 +523,8 @@ extern int blocknr_list_iterator(txn_atom *atom,/* These are wrappers for accessing and modifying atom's delete lists, depending on whether discard is enabled or not. -If it is enabled. both deferred and immediate delete lists are maintained, -and (less memory efficient) blocknr_lists are used for storage. Otherwise, only -deferred delete list is maintained and blocknr_set is used for its storage. */ +If it is enabled, (less memory efficient) blocknr_list is used for delete +list storage. Otherwise, blocknr_set is used for this purpose. */ extern void atom_dset_init (txn_atom *atom);extern void atom_dset_destroy (txn_atom *atom);extern void atom_dset_merge (txn_atom *from,txn_atom *to);@@ -541,10 +536,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom,void **new_entry, const reiser4_block_nr *start, const reiser4_block_nr *len); -extern int atom_dset_immediate_add_extent (txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len);/* flush code takes care about how to fuse flush queues */ extern void flush_init_atom (txn_atom * atom);
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
In reply to Edward ShishkinQuoted 16 lines
20 июля 2014 г., в 1:20, Edward Shishkin <[email protected]> написал(а):
Quoted 3 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
[...]
Quoted 7 lines
Quoted 2 lines
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...
Quoted 7 lines
False alarm, actually..
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing thecommit_mutex_after_ our discard. Everything is isolated.. For the same reason we don't care if someone allocate blocks in head and tail paddings before issuing our padded discard extents.
I was just thinking about the very same possible race...
But well, isn't the call to current_atom_complete_writes() placed before acquisition of commit_mutex? I was under impression of that relocate sets could be written while another atom is being committed under the mutex.
--
Ivan Shapovalov / intelfx /
(Sent from a phone. Havoc may be wreaked on the formatting.)
Quoted 7 lines
We only need to make sure that
they were clean at _our_ commit session.Anyway, let's use delayed deallocation. I like it better than
aux_delete_set. After all, we can roll everything back at every moment, if any problems..Edward.
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [veryRFC] [PATCH 2/2] reiser4: discard support: proof-of-concept for "discard before dealloc".
In reply to Edward ShishkinQuoted 64 lines
20 июля 2014 г., в 5:11, Edward Shishkin <[email protected]> написал(а):
Quoted 61 lines · Ivan Shapovalov
This is INCOMPLETE and needs a modified
discard_extent()because blocks inside of original extents are always allocated but allowed for discarding.Signed-off-by Ivan Shapovalov <[email protected]>--- fs/reiser4/block_alloc.c | 28 +++++----------------- fs/reiser4/discard.c | 60 ++++++++++++++++++++++++++++++++++-------------- fs/reiser4/discard.h | 4 +++- fs/reiser4/txnmgr.c | 24 ------------------- fs/reiser4/txnmgr.h | 13 ++--------- 5 files changed, 54 insertions(+), 75 deletions(-)fs/reiser4/block_alloc.c +4
-19@@ -1007,7 +1007,8 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_reiser4_super (sbinfo); } - if (flags & BA_DEFER) { +if ((flags &BA_DEFER ) || +reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {/* store deleted block numbers in the atom's deferred delete set for further actual deletion */ do {@@ -1028,25 +1029,6 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,spin_unlock_atom (atom); }else { -/* store deleted block numbers in the atom's immediate delete set -for further processing */ -do { - atom =get_current_atom_locked (); -assert ("intelfx-51" , atom !=NULL ); - - ret =atom_dset_immediate_add_extent (atom, &new_entry, start, len); - -if (ret == -ENOMEM ) -return ret; - -/* This loop might spin at most two times */ - }while (ret == -E_REPEAT ); - -assert ("intelfx-52" , ret ==0 ); -assert ("intelfx-53" , atom !=NULL ); - -spin_unlock_atom (atom); -assert ("zam-425" ,get_current_super_private () !=NULL );sa_dealloc_blocks (reiser4_get_space_allocator (ctx->super), *start, *len);@@ -1150,13 +1132,15 @@ void reiser4_post_commit_hook(void)void reiser4_post_write_back_hook (void ) { +struct list_head discard_tmp;txn_atom *atom;int ret;/* process and issue discard requests */ +blocknr_list_init (&discard_tmp); do { atom = get_current_atom_locked();
Quoted 8 lines
fs/reiser4/block_alloc.c void reiser4_post_commit_hook(void) · line 1144
Quoted 3 lines
fs/reiser4/block_alloc.c +1
-1- ret =discard_atom (*atom); + ret =discard_atom (*atom, &discard_tmp); }while (ret == -E_REPEAT );This is a leak of disk space on error paths:
if (ret != 0 && ret != -E_REPEAT), thendelete_setis empty, or incomplete at this point.
Yeah, I've missed this. I'll add a splice to discard_atom()'s error path.
Thanks,
--
Ivan Shapovalov / intelfx /
(Sent from a phone. Havoc may be wreaked on the formatting.)
Quoted 204 lines
Quoted 204 lines
fs/reiser4/block_alloc.c +1
-1if (ret) {@@ -1165,7 +1149,7 @@ void reiser4_post_write_back_hook(void)/* do the block deallocation which was deferred until commit is done */ -atom_dset_deferred_apply (atom, apply_dset,NULL ,0 ); +atom_dset_deferred_apply (atom, apply_dset,NULL ,1 );assert ("zam-504" ,get_current_super_private () !=NULL );sa_post_write_back_hook ();fs/reiser4/discard.c +43
-15@@ -33,24 +33,42 @@* MECHANISM: * * During the transaction deallocated extents are recorded in atom's delete -* sets. There are two delete sets, because data in one of them (delete_set) is -* also used by other parts of reiser4. The second delete set (aux_delete_set) -* complements the first one and is maintained only when discard is enabled. +* set. In reiser4, there are two methods to deallocate a block: +* 1. deferred deallocation, enabled by BA_DEFER flag to reiser4_dealloc_block(). +* In this mode, blocks are stored to delete set instead of being marked free +* immediately. After committing the transaction, the delete set is "applied" +* by the block allocator and all these blocks are marked free in memory +* (see reiser4_post_commit_hook()). +* Space management plugins also read the delete set to update on-disk +* allocation records (see reiser4_pre_commit_hook()). +* 2. immediate deallocation (the opposite). +* In this mode, blocks are marked free immediately. This is used by the +* journal subsystem to manage space used by the journal records, so these +* allocations are not visible to the space management plugins and never hit +* the disk. * -* Together these sets constitute "the discard set" -- blocks that have to be -* considered for discarding. On atom commit we will generate a minimal -* superset of the discard set, comprised of whole erase units. +* When discard is enabled, all immediate deallocations become deferred. This +* is OK because journal's allocations happen after reiser4_pre_commit_hook() +* where the on-disk space allocation records are updated. So, in this mode +* the atom's delete set becomes "the discard set" -- list of blocks that have +* to be considered for discarding. +* +* On atom commit we will generate a minimal superset of the discard set, +* comprised of whole erase units. +* +* Discarding is performed before reiser4_post_commit_hook(), hence all extents +* in the discard set are still marked as allocated and cannot contain any data. +* Thus we can avoid any checks for blocks directly present in the discard set. +* +* However, we pad each extent from both sides to erase unit boundaries, and +* these paddings still have to be checked if they fall outside of initial +* extent (may not happen if block size > erase unit size). * * So, at commit time the following actions take place: * - delete sets are merged to form the discard set; * - elements of the discard set are sorted; * - the discard set is iterated, joining any adjacent extents; -* - each of resulting extents is "covered" by erase units: -* - its start is rounded down to the closest erase unit boundary; -* - starting from this block, extents of erase unit length are created -* until the original extent is fully covered; -* - the calculated erase units are checked to be fully deallocated; -* - remaining (valid) erase units are then passed to blkdev_issue_discard(). +* - <TODO> */ #include "discard.h" @@ -167,7 +185,7 @@ static int discard_extent(txn_atom *atom UNUSED_ARG,return 0 ; } -int discard_atom(txn_atom *atom) +int discard_atom (txn_atom *atom,struct list_head *processed_set) {int ret;struct list_head discard_set;@@ -178,9 +196,14 @@ int discard_atom(txn_atom *atom) }assert ("intelfx-28" , atom !=NULL ); +assert ("intelfx-59" , processed_entries !=NULL ); - if (list_empty(&atom->discard.delete_set) && - list_empty(&atom->discard.aux_delete_set)) { + if (list_empty(&atom->discard.delete_set)) { +/* +* Nothing left to discard. Move all processed entries back to atom +* for reiser4_post_commit_hook(). +*/ +blocknr_list_merge (processed_set, &atom->discard.delete_set);spin_unlock_atom (atom);return 0 ; }@@ -188,14 +211,17 @@ int discard_atom(txn_atom *atom)/* Take the delete sets from the atom in order to release atom spinlock. */ blocknr_list_init (&discard_set);blocknr_list_merge (&atom->discard.delete_set, &discard_set); -blocknr_list_merge (&atom->discard.aux_delete_set, &discard_set);spin_unlock_atom (atom);/* Sort the discard list, joining adjacent and overlapping extents. */ blocknr_list_sort_and_join (&discard_set);/* Perform actual dirty work. */ - ret =blocknr_list_iterator (NULL , &discard_set, &discard_extent,NULL ,1 ); + ret =blocknr_list_iterator (NULL , &discard_set, &discard_extent,NULL ,0 ); + +/* Add processed extents to the temporary list. */ +blocknr_list_merge (&discard_set, processed_set); +if (ret !=0 ) {return ret; }fs/reiser4/discard.h +3
-1@@ -14,8 +14,10 @@* if discard is enabled. In this case the delete sets are cleared. * * @atom should be locked on entry and is unlocked on exit. +* @processed_set keeps state between invocations in -E_REPEAT pattern; +* must be initialized with blocknr_list_init(). */ -extern int discard_atom (txn_atom *atom); +extern int discard_atom (txn_atom *atom,struct list_head *processed_set);/* __FS_REISER4_DISCARD_H__ */ #endif fs/reiser4/txnmgr.c +0
-23@@ -3081,7 +3081,6 @@ void atom_dset_init(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_init (&atom->discard.delete_set); -blocknr_list_init (&atom->discard.aux_delete_set); }else {blocknr_set_init (&atom->nodiscard.delete_set); }@@ -3091,7 +3090,6 @@ void atom_dset_destroy(txn_atom *atom) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_destroy (&atom->discard.delete_set); -blocknr_list_destroy (&atom->discard.aux_delete_set); }else {blocknr_set_destroy (&atom->nodiscard.delete_set); }@@ -3101,7 +3099,6 @@ void atom_dset_merge(txn_atom *from, txn_atom *to) {if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) {blocknr_list_merge (&from->discard.delete_set, &to->discard.delete_set); -blocknr_list_merge (&from->discard.aux_delete_set, &to->discard.aux_delete_set); }else {blocknr_set_merge (&from->nodiscard.delete_set, &to->nodiscard.delete_set); }@@ -3155,27 +3152,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom,return ret; } -extern int atom_dset_immediate_add_extent(txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len) -{ -int ret; - -if (reiser4_is_set (reiser4_get_current_sb (),REISER4_DISCARD )) { - ret =blocknr_list_add_extent (atom, - &atom->discard.aux_delete_set, - (blocknr_list_entry **)new_entry, - start, - len); - }else { -/* no-op */ - ret =0 ; - } - -return ret; -} -/* * Local variables: * c-indentation-style: "K&R" fs/reiser4/txnmgr.h +0
-4@@ -259,10 +259,6 @@ struct txn_atom {/* The atom's delete set. It collects block numbers which were deallocated with BA_DEFER, i. e. of ordinary nodes. */ struct list_head delete_set; - -/* The atom's auxiliary delete set. It collects block numbers -which were deallocated without BA_DEFER, i. e. immediately. */ -struct list_head aux_delete_set; } discard; }; @@ -527,9 +523,8 @@ extern int blocknr_list_iterator(txn_atom *atom,/* These are wrappers for accessing and modifying atom's delete lists,
depending on whether discard is enabled or not.fs/reiser4/txnmgr.h +2
-3-If it is enabled. both deferred and immediate delete lists are maintained, -and (less memory efficient) blocknr_lists are used for storage. Otherwise, only -deferred delete list is maintained and blocknr_set is used for its storage. */ +If it is enabled, (less memory efficient) blocknr_list is used for delete +list storage. Otherwise, blocknr_set is used for this purpose. */ extern void atom_dset_init (txn_atom *atom);extern void atom_dset_destroy (txn_atom *atom);extern void atom_dset_merge (txn_atom *from,txn_atom *to);@@ -541,10 +536,6 @@ extern int atom_dset_deferred_add_extent(txn_atom *atom, void **new_entry,
Quoted 9 lines
fs/reiser4/txnmgr.h extern int atom_dset_deferred_add_extent(txn_atom *atom, · line 541
Quoted 8 lines
fs/reiser4/txnmgr.h +0
-4const reiser4_block_nr *start, const reiser4_block_nr *len); -extern int atom_dset_immediate_add_extent (txn_atom *atom, -void **new_entry, -const reiser4_block_nr *start, -const reiser4_block_nr *len);/* flush code takes care about how to fuse flush queues */ extern void flush_init_atom (txn_atom * atom);
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [veryRFC] [PATCH 0/2] reiser4: discard before dealloc: first approximation.
In reply to Edward ShishkinQuoted 22 lines
17 июля 2014 г., в 15:14, Edward Shishkin <[email protected]> написал(а):
Quoted 11 lines · Ivan Shapovalov
Quoted 10 lines · Edward Shishkin
Quoted 3 lines · Ivan Shapovalov
This needs your version of discard algorithm, because blocks inside extents of discard set are now marked as allocated.
OK, I'll try to finish it in weekends..
Quoted 1 line
BTW, have you dropped the case with erase unit size < block size?
Quoted 7 lines
Quoted 3 lines
In my version all erase units are supported except ones which are not a power of 2. We can support all erase units without exceptions, if needed.
I mean, when erase unit size < block size, erase unit size is forced to be exactly one block. Again, this is OK, but in this case any alignment (by definition less than one block then) will be dropped and represented as zero, and _this_ deserves a warning :)
Quoted 3 lines
The case of alignment %
block_size!= 0 deserves to disable discard support, because in this case all this science with heads and tails simply doesn't work.
<bikeshed>
If erase unit size == block size (or less than), then it's ok. We could in this case unconditionally consider a tail/head padding of 1 block without cutting tail/head in case of unavailable padding. But then again, </bikeshed>
--
Ivan Shapovalov / intelfx /
(Sent from a phone. Havoc may be wreaked on the formatting.)
Quoted 4 lines
Quoted 3 lines
// btw, as you probably guess, these two patches are completely untested.
Thanks,
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
In reply to Ivan ShapovalovQuoted 15 lines · Ivan Shapovalov
Quoted 15 lines
20 июля 2014 г., в 1:20, Edward Shishkin <[email protected]> написал(а):
Quoted 3 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
[...]
Quoted 5 lines
Quoted 1 line
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...False alarm, actually..
Quoted 8 lines
Quoted 5 lines
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing thecommit_mutex_after_ our discard. Everything is isolated.. For the same reason we don't care if someone allocate blocks in head and tail paddings before issuing our padded discard extents.I was just thinking about the very same possible race...
But well, isn't the call to
current_atom_complete_writes()placed before acquisition ofcommit_mutex? I was under impression of that relocate sets could be written while another atom is being committed under the mutex.
take the commit_mutex before flush if discard_enabled && should_check_heads.
Quoted 13 lines
--
Ivan Shapovalov / intelfx /(Sent from a phone. Havoc may be wreaked on the formatting.)
Quoted 7 lines
We only need to make sure that
they were clean at _our_ commit session.Anyway, let's use delayed deallocation. I like it better than
aux_delete_set. After all, we can roll everything back at every moment, if any problems..Edward.
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 22 lines · Edward Shishkin
Quoted 20 lines · Ivan Shapovalov
Quoted 20 lines
20 июля 2014 г., в 1:20, Edward Shishkin <[email protected]> написал(а):
Quoted 3 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
[...]
Quoted 5 lines
Quoted 1 line
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...False alarm, actually..
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing thecommit_mutex_after_ our discard. Everything is isolated.. For the same reason we don't care if someone allocate blocks in head and tail paddings before issuing our padded discard extents.
Quoted 5 lines
Quoted 3 lines
I was just thinking about the very same possible race...
But well, isn't the call to
current_atom_complete_writes()placed before acquisition ofcommit_mutex? I was under impression of that relocate sets could be written while another atom is being committed under the mutex.take the
commit_mutexbefore flush ifdiscard_enabled&&should_check_heads.
Actually, this is not so simple. E.g. I got a deadlock.. Another option is to make head/tail paddings dirty with the following update of the extent of the delete_set. One more option is to not support such discard params.
Edward.
Quoted 7 lines
Quoted 7 lines
Signature · 4 lines
-- Ivan Shapovalov / intelfx / (Sent from a phone. Havoc may be wreaked on the formatting.)
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
We only need to make sure that
they were clean at _our_ commit session.Anyway, let's use delayed deallocation. I like it better than
aux_delete_set. After all, we can roll everything back at every moment, if any problems..Edward.
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 28 lines · Edward Shishkin
Quoted 26 lines · Edward Shishkin
Quoted 23 lines · Ivan Shapovalov
Quoted 13 lines
20 июля 2014 г., в 1:20, Edward Shishkin <[email protected]> написал(а):
Quoted 3 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
[...]
Quoted 5 lines
Quoted 1 line
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...Quoted 7 lines
False alarm, actually..
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing thecommit_mutex_after_ our discard. Everything is isolated.. For the same reason we don't care if someone allocate blocks in head and tail paddings before issuing our padded discard extents.I was just thinking about the very same possible race...
But well, isn't the call to
current_atom_complete_writes()placed before acquisition ofcommit_mutex? I was under impression of that relocate sets could be written while another atom is being committed under the mutex.
Quoted 7 lines
Quoted 1 line
take the
commit_mutexbefore flush ifdiscard_enabled&&should_check_heads.Actually, this is not so simple. E.g. I got a deadlock.. Another option is to make head/tail paddings dirty with the following update of the extent of the
delete_set. One more option is to not support such discard params.
Actually what we are trying to implement is "precise discard". This is rather complicated task. I looked at other file systems: nobody bother with paddings, just stupidly pass a freed extent to blkdev_issue_discard(), which cuts the head and the tail. I suggest to do the same. We have done our best. Someone can not afford even to accumulate the extents.
Edward.
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 50 lines · Edward Shishkin
Quoted 38 lines · Edward Shishkin
Quoted 36 lines · Edward Shishkin
Quoted 33 lines · Ivan Shapovalov
Quoted 18 lines
20 июля 2014 г., в 1:20, Edward Shishkin
<[email protected]> написал(а):Quoted 3 lines · Edward Shishkin
Quoted 2 lines · Ivan Shapovalov
[...]
Quoted 7 lines
Quoted 1 line
Nothing seems to call at least
check_free_blocks(begin, end)...Oh, bad... I thought all this time that extents of the delete sets are still dirty
in the working bitmap at the moment of discard.
Hmm, I definitely don't want to check the whole extents for discard...False alarm, actually..
Quoted 9 lines
Nothing is wrong if someone makes them dirty before issuing our discard
requests: his changes will be committed in the next sessions of possessing
thecommit_mutex_after_ our discard. Everything is isolated.. For the same
reason we don't care if someone allocate blocks in head and tail paddings
before issuing our padded discard extents.I was just thinking about the very same possible race...
But well, isn't the call to
current_atom_complete_writes()placed before acquisition ofcommit_mutex? I was under impression of that relocate sets could be written while another atom is being committed under the mutex.Quoted 8 lines
Quoted 2 lines
take the
commit_mutexbefore flush ifdiscard_enabled&&should_check_heads.Actually, this is not so simple. E.g. I got a deadlock.. Another option is to make head/tail paddings dirty with the following update of the extent of the
delete_set. One more option is to not support such discard params.
Quoted 7 lines
Actually what we are trying to implement is "precise discard". This is rather complicated task. I looked at other file systems: nobody bother with paddings, just stupidly pass a freed extent to
blkdev_issue_discard(), which cuts the head and the tail. I suggest to do the same. We have done our best. Someone can not afford even to accumulate the extents.Edward.
Let's do it ideally, after all, this is reiser4 ;) I also think that we can just mark paddings as allocated and add them to extent in question (so that they will be freed by reiser4_post_commit_hook). This looks simple enough.
The block allocator interface, IIRC, allows us to tell it "allocate right here or return failure".
/* I had no time to look into any code during this weekend. Tomorrow I'll hopefully repost the discard-before-dealloc patches and look into this.. */
Signature · 1 line
Ivan Shapovalov / intelfx /
Re: [PATCHv6 3/5] reiser4: discard support: initial implementation using linked lists.
Quoted 1 line · Ivan Shapovalov
On Monday 21 July 2014 at 00:49:14, Edward Shishkin wrote:
[...]
Quoted 17 lines
Quoted 6 lines
Actually, this is not so simple. E.g. I got a deadlock.. Another option is to make head/tail paddings dirty with the following update of the extent of the
delete_set. One more option is to not support such discard params.Quoted 7 lines
Actually what we are trying to implement is "precise discard". This is rather complicated task. I looked at other file systems: nobody bother with paddings, just stupidly pass a freed extent to
blkdev_issue_discard(), which cuts the head and the tail. I suggest to do the same. We have done our best. Someone can not afford even to accumulate the extents.Edward.
Let's do it ideally, after all, this is reiser4 ;) I also think that we can just mark paddings as allocated and add them to extent in question (so that they will be freed by
reiser4_post_commit_hook). This looks simple enough.
Quoted 5 lines
The block allocator interface, IIRC, allows us to tell it "allocate right here or return failure".
/* I had no time to look into any code during this weekend. Tomorrow I'll hopefully repost the discard-before-dealloc patches and look into this.. */
I think we'll also need a "leftward" version of check_blocks() to check head paddings. The most unpleasant thing is when check fails at the next bitmap node. It seems that the most reasonable way in this case would be just to return 0 (dirty) and clear everything when applying the "updated" delete set.
Edward.