Motr  M0
fsync.c File Reference
#include <linux/version.h>
#include <linux/fs.h>
#include <linux/mount.h>
#include "lib/trace.h"
#include "mdservice/fsync_fops.h"
#include "fop/fom_generic.h"
#include "lib/memory.h"
#include "lib/tlist.h"
#include "lib/hash.h"
#include "file/file.h"
#include "motr/magic.h"
#include "m0t1fs/linux_kernel/m0t1fs.h"
#include "layout/pdclust.h"
#include "m0t1fs/linux_kernel/file_internal.h"
#include "m0t1fs/linux_kernel/fsync.h"
Include dependency graph for fsync.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_M0T1FS
 

Functions

 M0_TL_DESCR_DEFINE (fpf, "m0t1fs_fsync_fop_wrappers pending fsync-fops", static, struct m0t1fs_fsync_fop_wrapper, ffw_tlink, ffw_tlink_magic, M0_T1FS_FFW_TLIST_MAGIC1, M0_T1FS_FFW_TLIST_MAGIC2)
 
 M0_TL_DEFINE (fpf, static, struct m0t1fs_fsync_fop_wrapper)
 
static void m0t1fs_fsync_fop_cleanup (struct m0_ref *ref)
 
int m0t1fs_fsync_request_create (struct m0_reqh_service_txid *stx, struct m0t1fs_fsync_fop_wrapper **ffw_out, enum m0_fsync_mode mode)
 
static void fsync_stx_update (struct m0_reqh_service_txid *stx, uint64_t txid, struct m0_mutex *lock)
 
int m0t1fs_fsync_reply_process (struct m0t1fs_sb *csb, struct m0t1fs_inode *inode, struct m0t1fs_fsync_fop_wrapper *ffw)
 
int m0t1fs_fsync_core (struct m0t1fs_inode *inode, enum m0_fsync_mode mode)
 
int m0t1fs_fsync (struct file *file, loff_t start, loff_t end, int datasync)
 
void m0t1fs_fsync_record_update (struct m0_reqh_service_ctx *service, struct m0t1fs_sb *csb, struct m0t1fs_inode *inode, struct m0_be_tx_remid *btr)
 
int m0t1fs_sync_fs (struct super_block *sb, int wait)
 

Variables

struct m0t1fs_fsync_interactions fi
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_M0T1FS

Definition at line 27 of file fsync.c.

Function Documentation

◆ fsync_stx_update()

static void fsync_stx_update ( struct m0_reqh_service_txid stx,
uint64_t  txid,
struct m0_mutex lock 
)
static

Definition at line 174 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ M0_TL_DEFINE()

M0_TL_DEFINE ( fpf  ,
static  ,
struct m0t1fs_fsync_fop_wrapper   
)

◆ M0_TL_DESCR_DEFINE()

M0_TL_DESCR_DEFINE ( fpf  ,
"m0t1fs_fsync_fop_wrappers pending fsync-fops"  ,
static  ,
struct m0t1fs_fsync_fop_wrapper  ,
ffw_tlink  ,
ffw_tlink_magic  ,
M0_T1FS_FFW_TLIST_MAGIC1  ,
M0_T1FS_FFW_TLIST_MAGIC2   
)

◆ m0t1fs_fsync()

int m0t1fs_fsync ( struct file file,
loff_t  start,
loff_t  end,
int  datasync 
)

Entry point for fsync, calls m0t1fs_fsync_core with mode=active

parameter dentry is unused as we don't need it - it is removed in later kernel versions

parameter datasync is unused, as we only ever sync data. To sync metadata would require a sync against the super-block, as all metadata currently lives in container-zero.

Failure

Todo:
: Generate some addb here.

Definition at line 354 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_fsync_core()

int m0t1fs_fsync_core ( struct m0t1fs_inode *  inode,
enum m0_fsync_mode  mode 
)

m0t1fs fsync core sends an fsync-fop to a list of services, then blocks, waiting for replies. This is implemented as two loops. The 'fop sending loop', generates and posts fops, adding them to a list of pending fops. This is all done while holding the m0t1fs_indode::ci_service_pending_txid_map_lock. The 'reply receiving loop' works over the list of pending fops, waiting for a reply for each one. It acquires the m0t1fs_indode::ci_service_pending_txid_map_lock only when necessary.

Definition at line 281 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_fsync_fop_cleanup()

static void m0t1fs_fsync_fop_cleanup ( struct m0_ref ref)
static

Cleans-up a fop.

Definition at line 82 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_fsync_record_update()

void m0t1fs_fsync_record_update ( struct m0_reqh_service_ctx service,
struct m0t1fs_sb *  csb,
struct m0t1fs_inode *  inode,
struct m0_be_tx_remid btr 
)

Update a m0_reqh_service_txid with the specified be_tx_remid if the struct m0_be_tx_remid::tri_txid > the stored value inode may be NULL if the update has no associated inode. csb may be NULL, iff inode is specified.

Definition at line 397 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_fsync_reply_process()

int m0t1fs_fsync_reply_process ( struct m0t1fs_sb *  csb,
struct m0t1fs_inode *  inode,
struct m0t1fs_fsync_fop_wrapper ffw 
)

Waits for a reply to an fsync fop and process it. Cleans-up the fop allocated in m0t1fs_fsync_request_create.

inode may be NULL if the reply is only likely to touch the super block. csb may be NULL, iff inode is specified.

Definition at line 206 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_fsync_request_create()

int m0t1fs_fsync_request_create ( struct m0_reqh_service_txid stx,
struct m0t1fs_fsync_fop_wrapper **  ffw_out,
enum m0_fsync_mode  mode 
)

Creates and sends an fsync fop from the provided m0_reqh_service_txid. Allocates and returns the fop wrapper at on success, which is freed on the last m0_fop_put().

Definition at line 105 of file fsync.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0t1fs_sync_fs()

int m0t1fs_sync_fs ( struct super_block sb,
int  wait 
)

Entry point for sync_fs, sends fsync-fops for each pending transaction the super block is aware off. Unlike m0t1fs_fsync_core this function acquires the sc_max_pending_tx_lock for each service, as there is not a larger-granularity lock.

Definition at line 462 of file fsync.c.

Here is the call graph for this function:

Variable Documentation

◆ fi

Initial value:
= {
.kernel_fsync = __generic_file_fsync,
.post_rpc = &m0_rpc_post,
.wait_for_reply = &m0_rpc_item_wait_for_reply,
.fop_fini = &m0_fop_fini,
.fop_put = &m0_fop_put_lock,
}
M0_INTERNAL int m0_rpc_post(struct m0_rpc_item *item)
Definition: rpc.c:63
int m0_rpc_item_wait_for_reply(struct m0_rpc_item *item, m0_time_t timeout)
Definition: item.c:824
M0_INTERNAL void m0_fop_fini(struct m0_fop *fop)
Definition: fop.c:136
void m0_fop_put_lock(struct m0_fop *fop)
Definition: fop.c:199

Ugly abstraction of m0t1fs_fsync interactions with wider motr code

  • purely to facilitate unit testing

Definition at line 55 of file fsync.c.