Commit e5150163 authored by Edward Shishkin's avatar Edward Shishkin Committed by james toy

. Rename confusing "psched" to "dispatch";

. Cleanups.
Signed-off-by: default avatarEdward Shishkin <edward.shishkin@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 552561c8
...@@ -2642,7 +2642,7 @@ void reset_cluster_params(struct cluster_handle * clust) ...@@ -2642,7 +2642,7 @@ void reset_cluster_params(struct cluster_handle * clust)
/* the heart of write_cryptcompress */ /* the heart of write_cryptcompress */
static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, static loff_t do_write_cryptcompress(struct file *file, struct inode *inode,
const char __user *buf, size_t to_write, const char __user *buf, size_t to_write,
loff_t pos, struct psched_context *cont) loff_t pos, struct dispatch_context *cont)
{ {
int i; int i;
hint_t *hint; hint_t *hint;
...@@ -2683,10 +2683,8 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, ...@@ -2683,10 +2683,8 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode,
if (next_window_stat(&win) == HOLE_WINDOW) { if (next_window_stat(&win) == HOLE_WINDOW) {
/* write hole in this iteration /* write hole in this iteration
separated from the loop below */ separated from the loop below */
result = write_pschedule_hook(file, inode, result = write_dispatch_hook(file, inode,
pos, pos, &clust, cont);
&clust,
cont);
if (result) if (result)
goto out; goto out;
result = prepare_logical_cluster(inode, pos, count, &clust, result = prepare_logical_cluster(inode, pos, count, &clust,
...@@ -2700,14 +2698,13 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, ...@@ -2700,14 +2698,13 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode,
assert("edward-750", reiser4_schedulable()); assert("edward-750", reiser4_schedulable());
result = write_pschedule_hook(file, inode, result = write_dispatch_hook(file, inode,
pos + to_write - count, pos + to_write - count,
&clust, &clust, cont);
cont);
if (result) if (result)
goto out; goto out;
if (cont->state == PSCHED_ASSIGNED_NEW) if (cont->state == DISPATCH_ASSIGNED_NEW)
/* done_lh was called in write_pschedule_hook */ /* done_lh was called in write_dispatch_hook */
goto out_no_longterm_lock; goto out_no_longterm_lock;
result = prepare_logical_cluster(inode, pos, count, &clust, result = prepare_logical_cluster(inode, pos, count, &clust,
...@@ -2787,7 +2784,7 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, ...@@ -2787,7 +2784,7 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode,
put_cluster_handle(&clust); put_cluster_handle(&clust);
assert("edward-195", assert("edward-195",
ergo((to_write == count), ergo((to_write == count),
(result < 0 || cont->state == PSCHED_ASSIGNED_NEW))); (result < 0 || cont->state == DISPATCH_ASSIGNED_NEW)));
return (to_write - count) ? (to_write - count) : result; return (to_write - count) ? (to_write - count) : result;
} }
...@@ -2800,7 +2797,7 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, ...@@ -2800,7 +2797,7 @@ static loff_t do_write_cryptcompress(struct file *file, struct inode *inode,
*/ */
ssize_t write_cryptcompress(struct file *file, const char __user *buf, ssize_t write_cryptcompress(struct file *file, const char __user *buf,
size_t count, loff_t *off, size_t count, loff_t *off,
struct psched_context *cont) struct dispatch_context *cont)
{ {
ssize_t result; ssize_t result;
struct inode *inode; struct inode *inode;
...@@ -2808,7 +2805,7 @@ ssize_t write_cryptcompress(struct file *file, const char __user *buf, ...@@ -2808,7 +2805,7 @@ ssize_t write_cryptcompress(struct file *file, const char __user *buf,
loff_t pos = *off; loff_t pos = *off;
struct cryptcompress_info *info; struct cryptcompress_info *info;
assert("edward-1449", cont->state == PSCHED_INVAL_STATE); assert("edward-1449", cont->state == DISPATCH_INVAL_STATE);
inode = file->f_dentry->d_inode; inode = file->f_dentry->d_inode;
assert("edward-196", cryptcompress_inode_ok(inode)); assert("edward-196", cryptcompress_inode_ok(inode));
...@@ -3701,7 +3698,7 @@ int setattr_cryptcompress(struct dentry *dentry, struct iattr *attr) ...@@ -3701,7 +3698,7 @@ int setattr_cryptcompress(struct dentry *dentry, struct iattr *attr)
ctx = reiser4_init_context(dentry->d_inode->i_sb); ctx = reiser4_init_context(dentry->d_inode->i_sb);
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return PTR_ERR(ctx); return PTR_ERR(ctx);
result = setattr_pschedule_hook(inode); result = setattr_dispatch_hook(inode);
if (result) { if (result) {
context_set_commit_async(ctx); context_set_commit_async(ctx);
reiser4_exit_context(ctx); reiser4_exit_context(ctx);
......
...@@ -562,10 +562,10 @@ int bind_cryptcompress(struct inode *child, struct inode *parent); ...@@ -562,10 +562,10 @@ int bind_cryptcompress(struct inode *child, struct inode *parent);
void destroy_inode_cryptcompress(struct inode * inode); void destroy_inode_cryptcompress(struct inode * inode);
int grab_page_cluster(struct inode *inode, struct cluster_handle * clust, int grab_page_cluster(struct inode *inode, struct cluster_handle * clust,
rw_op rw); rw_op rw);
int write_pschedule_hook(struct file *file, struct inode * inode, int write_dispatch_hook(struct file *file, struct inode * inode,
loff_t pos, struct cluster_handle * clust, loff_t pos, struct cluster_handle * clust,
struct psched_context * cont); struct dispatch_context * cont);
int setattr_pschedule_hook(struct inode * inode); int setattr_dispatch_hook(struct inode * inode);
struct reiser4_crypto_info * inode_crypto_info(struct inode * inode); struct reiser4_crypto_info * inode_crypto_info(struct inode * inode);
void inherit_crypto_info_common(struct inode * parent, struct inode * object, void inherit_crypto_info_common(struct inode * parent, struct inode * object,
int (*can_inherit)(struct inode * child, int (*can_inherit)(struct inode * child,
......
...@@ -2059,8 +2059,10 @@ static void drop_access(struct unix_file_info *uf_info) ...@@ -2059,8 +2059,10 @@ static void drop_access(struct unix_file_info *uf_info)
* @cont: unused argument, as we don't perform plugin conversion when being * @cont: unused argument, as we don't perform plugin conversion when being
* managed by unix_file plugin. * managed by unix_file plugin.
*/ */
ssize_t write_unix_file(struct file *file, const char __user *buf, ssize_t write_unix_file(struct file *file,
size_t count, loff_t *pos, struct psched_context *cont) const char __user *buf,
size_t count, loff_t *pos,
struct dispatch_context *cont)
{ {
int result; int result;
reiser4_context *ctx; reiser4_context *ctx;
......
...@@ -8,18 +8,18 @@ ...@@ -8,18 +8,18 @@
#if !defined( __REISER4_FILE_H__ ) #if !defined( __REISER4_FILE_H__ )
#define __REISER4_FILE_H__ #define __REISER4_FILE_H__
/* possible states when scheduling a new file plugin */ /* possible states in dispatching process */
typedef enum { typedef enum {
PSCHED_INVAL_STATE, /* invalid state */ DISPATCH_INVAL_STATE, /* invalid state */
PSCHED_SCHED_POINT, /* scheduling point has been achieved */ DISPATCH_POINT, /* dispatching point has been achieved */
PSCHED_REMAINS_OLD, /* made a decision to be managed by old plugin */ DISPATCH_REMAINS_OLD, /* made a decision to manage by old plugin */
PSCHED_ASSIGNED_NEW /* new plugin has been scheduled */ DISPATCH_ASSIGNED_NEW /* a new plugin has been assigned */
} psched_state; } dispatch_state;
struct psched_context { struct dispatch_context {
int nr_pages; int nr_pages;
struct page **pages; struct page **pages;
psched_state state; dispatch_state state;
}; };
/** /**
...@@ -82,7 +82,7 @@ int setattr_unix_file(struct dentry *, struct iattr *); ...@@ -82,7 +82,7 @@ int setattr_unix_file(struct dentry *, struct iattr *);
ssize_t read_unix_file(struct file *, char __user *buf, size_t read_amount, ssize_t read_unix_file(struct file *, char __user *buf, size_t read_amount,
loff_t *off); loff_t *off);
ssize_t write_unix_file(struct file *, const char __user *buf, size_t write_amount, ssize_t write_unix_file(struct file *, const char __user *buf, size_t write_amount,
loff_t * off, struct psched_context * cont); loff_t * off, struct dispatch_context * cont);
int ioctl_unix_file(struct inode *, struct file *, unsigned int cmd, int ioctl_unix_file(struct inode *, struct file *, unsigned int cmd,
unsigned long arg); unsigned long arg);
int mmap_unix_file(struct file *, struct vm_area_struct *); int mmap_unix_file(struct file *, struct vm_area_struct *);
...@@ -121,7 +121,7 @@ ssize_t read_cryptcompress(struct file *, char __user *buf, ...@@ -121,7 +121,7 @@ ssize_t read_cryptcompress(struct file *, char __user *buf,
size_t count, loff_t *off); size_t count, loff_t *off);
ssize_t write_cryptcompress(struct file *, const char __user *buf, ssize_t write_cryptcompress(struct file *, const char __user *buf,
size_t count, loff_t * off, size_t count, loff_t * off,
struct psched_context *cont); struct dispatch_context *cont);
int ioctl_cryptcompress(struct inode *, struct file *, unsigned int cmd, int ioctl_cryptcompress(struct inode *, struct file *, unsigned int cmd,
unsigned long arg); unsigned long arg);
int mmap_cryptcompress(struct file *, struct vm_area_struct *); int mmap_cryptcompress(struct file *, struct vm_area_struct *);
......
...@@ -2,62 +2,30 @@ ...@@ -2,62 +2,30 @@
licensing governed by reiser4/README */ licensing governed by reiser4/README */
/** /**
* This file contains plugin schedule hooks, and plugin conversion methods. * This file contains dispatching hooks, and conversion methods, which
* implement transitions in the FILE interface.
* *
* Plugin schedule hook makes a decision (at plugin schedule point) about the * Dispatching hook makes a decision (at dispatching point) about the
* most reasonable plugins for managing a regular file. Usually such decisions * most reasonable plugin. Such decision is made in accordance with some
* is made by some O(1)-heuristic. * O(1)-heuristic.
* *
* By default we assign a unix_file plugin id when writing incompressible file * We implement a transition CRYPTCOMPRESS -> UNIX_FILE for files with
* managed by cryptcompress plugin id. Currently used heuristic for estimating * incompressible data. Current heuristic to estimate compressibility is
* compressibility is very simple: if first complete logical cluster (64K by * very simple: if first complete logical cluster (64K by default) of a
* default) of a file is incompressible, then we make a decision, that the whole * file is incompressible, then we make a decision, that the whole file
* file is incompressible (*). * is incompressible.
* *
* To enable a conversion we install a special "magic" compression mode plugin * To enable dispatching we install a special "magic" compression mode
* (CONVX_COMPRESSION_MODE_ID, see plugin/compress/compress_mode.c for details) * plugin CONVX_COMPRESSION_MODE_ID at file creation time.
* at file creation time (**).
* *
* Note, that we don't perform back conversion (unix_file->cryptcompress) * Note, that we don't perform back conversion (UNIX_FILE->CRYPTCOMPRESS)
* because of compatibility reasons (see http://dev.namesys.com/Version4.X.Y * because of compatibility reasons).
* for details).
* *
* The conversion is accompanied by rebuilding disk structures of a file, so it * In conversion time we protect CS, the conversion set (file's (meta)data
* is important to protect them from being interacted with other plugins which * and plugin table (pset)) via special per-inode rw-semaphore (conv_sem).
* don't expect them to be in such inconsistent state. For this to be protected * The methods which implement conversion are CS writers. The methods of FS
* we serialize readers and writers of a file's conversion set (FCS). * interface (file_operations, inode_operations, address_space_operations)
* * are CS readers.
* We define FCS as a file plugin installed in inode's pset plus file's data
* and metadata that this file plugin manipulates with (items, etc).
* Note, that FCS is defined per file.
* FCS reader is defined as a set of instruction of the following type:
* {inode_file_plugin(inode)->method()} (I.e. retrieving a file plugin id
* conjoined with all method's instructions should be atomic).
* FCS writer is a set of instructions that perform file plugin conversion
* (convert items, update pset, etc).
* Example:
* reiser4_write_careful() supplied to VFS as a ->write() file operation is
* composed of the following (optional) instructions:
* 1 2 3
* *********************** ####### -------------------------------------------->
*
* 1) "****" are instructions performed on behalf of cryptcompress file plugin;
* 2) "####" is a FCS writer (performing a conversion cryptcompress->unix_file);
* 3) "----" are instructions performed on behalf of unix_file plugin;
* Here (1) and (3) are FCS readers.
*
* In this example FCS readers and writers are already serialized (by design),
* however there can be readers and writers executing at the same time in
* different contexts, so we need a common mechanism of serialization.
*
* Currently serialization of FCS readers and writers is performed via acquiring
* a special per-inode rw-semaphore (conv_sem). And yes, {down, up}_read is for
* FCS readers, and {down, up}_write is for FCS writers, see the macros below
* for passive/active protection.
*
* ---
* (*) This heuristic can be changed to a better one (benchmarking is needed).
* (**) Such technique allows to keep enable/disable state on disk.
*/ */
#include "../../inode.h" #include "../../inode.h"
...@@ -212,11 +180,11 @@ static int disable_conversion(struct inode * inode) ...@@ -212,11 +180,11 @@ static int disable_conversion(struct inode * inode)
/** /**
* Check if we really have achieved plugin scheduling point * Check if we really have achieved plugin scheduling point
*/ */
static int check_psched_point(struct inode * inode, static int check_dispatch_point(struct inode * inode,
loff_t pos /* position in the loff_t pos /* position in the
file to write from */, file to write from */,
struct cluster_handle * clust, struct cluster_handle * clust,
struct psched_context * cont) struct dispatch_context * cont)
{ {
assert("edward-1505", conversion_enabled(inode)); assert("edward-1505", conversion_enabled(inode));
/* /*
...@@ -241,9 +209,9 @@ static int check_psched_point(struct inode * inode, ...@@ -241,9 +209,9 @@ static int check_psched_point(struct inode * inode,
pos == inode->i_size && pos == inode->i_size &&
pos == inode_cluster_size(inode)); pos == inode_cluster_size(inode));
assert("edward-1539", cont != NULL); assert("edward-1539", cont != NULL);
assert("edward-1540", cont->state == PSCHED_INVAL_STATE); assert("edward-1540", cont->state == DISPATCH_INVAL_STATE);
cont->state = PSCHED_SCHED_POINT; cont->state = DISPATCH_POINT;
return 0; return 0;
} }
...@@ -301,14 +269,14 @@ static int prepped_dclust_ok(hint_t * hint) ...@@ -301,14 +269,14 @@ static int prepped_dclust_ok(hint_t * hint)
*/ */
static int read_check_compressibility(struct inode * inode, static int read_check_compressibility(struct inode * inode,
struct cluster_handle * clust, struct cluster_handle * clust,
struct psched_context * cont) struct dispatch_context * cont)
{ {
int i; int i;
int result; int result;
__u32 dst_len; __u32 dst_len;
hint_t tmp_hint; hint_t tmp_hint;
hint_t * cur_hint = clust->hint; hint_t * cur_hint = clust->hint;
assert("edward-1541", cont->state == PSCHED_SCHED_POINT); assert("edward-1541", cont->state == DISPATCH_POINT);
start_check_compressibility(inode, clust, &tmp_hint); start_check_compressibility(inode, clust, &tmp_hint);
...@@ -373,8 +341,8 @@ static int read_check_compressibility(struct inode * inode, ...@@ -373,8 +341,8 @@ static int read_check_compressibility(struct inode * inode,
finish_check_compressibility(inode, clust, cur_hint); finish_check_compressibility(inode, clust, cur_hint);
cont->state = cont->state =
(data_is_compressible(dst_len, inode_cluster_size(inode)) ? (data_is_compressible(dst_len, inode_cluster_size(inode)) ?
PSCHED_REMAINS_OLD : DISPATCH_REMAINS_OLD :
PSCHED_ASSIGNED_NEW); DISPATCH_ASSIGNED_NEW);
return 0; return 0;
error: error:
put_page_cluster(clust, inode, READ_OP); put_page_cluster(clust, inode, READ_OP);
...@@ -433,8 +401,8 @@ static int reserve_cryptcompress2unixfile(struct inode *inode) ...@@ -433,8 +401,8 @@ static int reserve_cryptcompress2unixfile(struct inode *inode)
/** /**
* Convert cryptcompress file plugin to unix_file plugin. * Convert cryptcompress file plugin to unix_file plugin.
*/ */
static int cryptcompress2unixfile(struct file * file, struct inode * inode, static int cryptcompress2unixfile(struct file *file, struct inode *inode,
struct psched_context * cont) struct dispatch_context *cont)
{ {
int i; int i;
int result = 0; int result = 0;
...@@ -490,28 +458,28 @@ static int cryptcompress2unixfile(struct file * file, struct inode * inode, ...@@ -490,28 +458,28 @@ static int cryptcompress2unixfile(struct file * file, struct inode * inode,
* Make a decision about the most reasonable file plugin id to manage * Make a decision about the most reasonable file plugin id to manage
* the file. * the file.
*/ */
int write_pschedule_hook(struct file * file, struct inode * inode, int write_dispatch_hook(struct file *file, struct inode *inode,
loff_t pos, struct cluster_handle * clust, loff_t pos, struct cluster_handle *clust,
struct psched_context * cont) struct dispatch_context *cont)
{ {
int result; int result;
if (!conversion_enabled(inode)) if (!conversion_enabled(inode))
return 0; return 0;
result = check_psched_point(inode, pos, clust, cont); result = check_dispatch_point(inode, pos, clust, cont);
if (result || cont->state != PSCHED_SCHED_POINT) if (result || cont->state != DISPATCH_POINT)
return result; return result;
result = read_check_compressibility(inode, clust, cont); result = read_check_compressibility(inode, clust, cont);
if (result) if (result)
return result; return result;
if (cont->state == PSCHED_REMAINS_OLD) { if (cont->state == DISPATCH_REMAINS_OLD) {
put_page_cluster(clust, inode, READ_OP); put_page_cluster(clust, inode, READ_OP);
return disable_conversion(inode); return disable_conversion(inode);
} }
assert("edward-1543", cont->state == PSCHED_ASSIGNED_NEW); assert("edward-1543", cont->state == DISPATCH_ASSIGNED_NEW);
/* /*
* page cluster is grabbed and uptodate. It will be * page cluster is grabbed and uptodate. It will be
* released with a pgset after plugin conversion is * released with a pgset after plugin conversion is
* finished, see put_psched_context(). * finished, see put_dispatch_context().
*/ */
reiser4_unset_hint(clust->hint); reiser4_unset_hint(clust->hint);
move_cluster_pgset(clust, &cont->pages, &cont->nr_pages); move_cluster_pgset(clust, &cont->pages, &cont->nr_pages);
...@@ -521,19 +489,19 @@ int write_pschedule_hook(struct file * file, struct inode * inode, ...@@ -521,19 +489,19 @@ int write_pschedule_hook(struct file * file, struct inode * inode,
/** /**
* This is called by ->setattr() method of cryptcompress file plugin. * This is called by ->setattr() method of cryptcompress file plugin.
*/ */
int setattr_pschedule_hook(struct inode * inode) int setattr_dispatch_hook(struct inode * inode)
{ {
if (conversion_enabled(inode)) if (conversion_enabled(inode))
return disable_conversion(inode); return disable_conversion(inode);
return 0; return 0;
} }
static inline void init_psched_context(struct psched_context * cont) static inline void init_dispatch_context(struct dispatch_context * cont)
{ {
memset(cont, 0, sizeof(*cont)); memset(cont, 0, sizeof(*cont));
} }
static inline void done_psched_context(struct psched_context * cont, static inline void done_dispatch_context(struct dispatch_context * cont,
struct inode * inode) struct inode * inode)
{ {
if (cont->pages) { if (cont->pages) {
...@@ -564,13 +532,13 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf, ...@@ -564,13 +532,13 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf,
reiser4_context *ctx; reiser4_context *ctx;
ssize_t written_old = 0; /* bytes written with initial plugin */ ssize_t written_old = 0; /* bytes written with initial plugin */
ssize_t written_new = 0; /* bytes written with new plugin */ ssize_t written_new = 0; /* bytes written with new plugin */
struct psched_context cont; struct dispatch_context cont;
struct inode * inode = file->f_dentry->d_inode; struct inode * inode = file->f_dentry->d_inode;
ctx = reiser4_init_context(inode->i_sb); ctx = reiser4_init_context(inode->i_sb);
if (IS_ERR(ctx)) if (IS_ERR(ctx))
return PTR_ERR(ctx); return PTR_ERR(ctx);
init_psched_context(&cont); init_dispatch_context(&cont);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
/** /**
* First step. * First step.
...@@ -582,7 +550,7 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf, ...@@ -582,7 +550,7 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf,
count, count,
off, off,
&cont); &cont);
if (cont.state != PSCHED_ASSIGNED_NEW || written_old < 0) if (cont.state != DISPATCH_ASSIGNED_NEW || written_old < 0)
goto exit; goto exit;
/** /**
* Second step. * Second step.
...@@ -616,7 +584,7 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf, ...@@ -616,7 +584,7 @@ ssize_t reiser4_write_careful(struct file *file, const char __user *buf,
NULL); NULL);
exit: exit:
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
done_psched_context(&cont, inode); done_dispatch_context(&cont, inode);
reiser4_exit_context(ctx); reiser4_exit_context(ctx);
return written_old + (written_new < 0 ? 0 : written_new); return written_old + (written_new < 0 ? 0 : written_new);
......
...@@ -235,7 +235,7 @@ typedef struct file_plugin { ...@@ -235,7 +235,7 @@ typedef struct file_plugin {
* in @cont */ * in @cont */
ssize_t (*write) (struct file *, const char __user *buf, ssize_t (*write) (struct file *, const char __user *buf,
size_t write_amount, loff_t * off, size_t write_amount, loff_t * off,
struct psched_context * cont); struct dispatch_context * cont);
int (*ioctl) (struct inode *inode, struct file *filp, int (*ioctl) (struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
int (*mmap) (struct file *, struct vm_area_struct *); int (*mmap) (struct file *, struct vm_area_struct *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment