2018-09-05 06:46:30 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2009-04-07 10:01:28 +08:00
|
|
|
/*
|
2021-11-09 10:35:01 +08:00
|
|
|
* NILFS meta data file prototype and definitions
|
2009-04-07 10:01:28 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
|
|
|
|
*
|
2016-05-24 07:23:09 +08:00
|
|
|
* Written by Ryusuke Konishi.
|
2009-04-07 10:01:28 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NILFS_MDT_H
|
|
|
|
#define _NILFS_MDT_H
|
|
|
|
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/blockgroup_lock.h>
|
|
|
|
#include "nilfs.h"
|
|
|
|
#include "page.h"
|
|
|
|
|
2012-07-31 05:42:10 +08:00
|
|
|
/**
|
|
|
|
* struct nilfs_shadow_map - shadow mapping of meta data file
|
|
|
|
* @bmap_store: shadow copy of bmap state
|
2022-04-02 02:28:21 +08:00
|
|
|
* @inode: holder of page caches used in shadow mapping
|
2012-07-31 05:42:10 +08:00
|
|
|
* @frozen_buffers: list of frozen buffers
|
|
|
|
*/
|
2010-09-06 11:05:43 +08:00
|
|
|
struct nilfs_shadow_map {
|
|
|
|
struct nilfs_bmap_store bmap_store;
|
2022-04-02 02:28:21 +08:00
|
|
|
struct inode *inode;
|
2010-09-06 11:05:43 +08:00
|
|
|
struct list_head frozen_buffers;
|
|
|
|
};
|
|
|
|
|
2009-04-07 10:01:28 +08:00
|
|
|
/**
|
|
|
|
* struct nilfs_mdt_info - on-memory private data of meta data files
|
|
|
|
* @mi_sem: reader/writer semaphore for meta data operations
|
|
|
|
* @mi_bgl: per-blockgroup locking
|
|
|
|
* @mi_entry_size: size of an entry
|
|
|
|
* @mi_first_entry_offset: offset to the first entry
|
|
|
|
* @mi_entries_per_block: number of entries in a block
|
2009-11-14 14:54:27 +08:00
|
|
|
* @mi_palloc_cache: persistent object allocator cache
|
2010-09-06 11:05:43 +08:00
|
|
|
* @mi_shadow: shadow of bmap and page caches
|
2009-04-07 10:01:28 +08:00
|
|
|
* @mi_blocks_per_group: number of blocks in a group
|
|
|
|
* @mi_blocks_per_desc_block: number of blocks per descriptor block
|
|
|
|
*/
|
|
|
|
struct nilfs_mdt_info {
|
|
|
|
struct rw_semaphore mi_sem;
|
|
|
|
struct blockgroup_lock *mi_bgl;
|
2016-05-24 07:23:39 +08:00
|
|
|
unsigned int mi_entry_size;
|
|
|
|
unsigned int mi_first_entry_offset;
|
2009-04-07 10:01:28 +08:00
|
|
|
unsigned long mi_entries_per_block;
|
2009-11-14 14:54:27 +08:00
|
|
|
struct nilfs_palloc_cache *mi_palloc_cache;
|
2010-09-06 11:05:43 +08:00
|
|
|
struct nilfs_shadow_map *mi_shadow;
|
2009-04-07 10:01:28 +08:00
|
|
|
unsigned long mi_blocks_per_group;
|
|
|
|
unsigned long mi_blocks_per_desc_block;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct nilfs_mdt_info *NILFS_MDT(const struct inode *inode)
|
|
|
|
{
|
|
|
|
return inode->i_private;
|
|
|
|
}
|
|
|
|
|
2016-05-24 07:23:20 +08:00
|
|
|
static inline int nilfs_is_metadata_file_inode(const struct inode *inode)
|
|
|
|
{
|
|
|
|
return inode->i_private != NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-07 10:01:28 +08:00
|
|
|
/* Default GFP flags using highmem */
|
2015-11-07 08:28:28 +08:00
|
|
|
#define NILFS_MDT_GFP (__GFP_RECLAIM | __GFP_IO | __GFP_HIGHMEM)
|
2009-04-07 10:01:28 +08:00
|
|
|
|
|
|
|
int nilfs_mdt_get_block(struct inode *, unsigned long, int,
|
|
|
|
void (*init_block)(struct inode *,
|
|
|
|
struct buffer_head *, void *),
|
|
|
|
struct buffer_head **);
|
2015-04-17 03:46:39 +08:00
|
|
|
int nilfs_mdt_find_block(struct inode *inode, unsigned long start,
|
|
|
|
unsigned long end, unsigned long *blkoff,
|
|
|
|
struct buffer_head **out_bh);
|
2009-04-07 10:01:28 +08:00
|
|
|
int nilfs_mdt_delete_block(struct inode *, unsigned long);
|
|
|
|
int nilfs_mdt_forget_block(struct inode *, unsigned long);
|
|
|
|
int nilfs_mdt_fetch_dirty(struct inode *);
|
|
|
|
|
2010-09-05 11:20:59 +08:00
|
|
|
int nilfs_mdt_init(struct inode *inode, gfp_t gfp_mask, size_t objsz);
|
2016-05-24 07:23:20 +08:00
|
|
|
void nilfs_mdt_clear(struct inode *inode);
|
|
|
|
void nilfs_mdt_destroy(struct inode *inode);
|
|
|
|
|
2016-05-24 07:23:39 +08:00
|
|
|
void nilfs_mdt_set_entry_size(struct inode *, unsigned int, unsigned int);
|
2009-04-07 10:01:28 +08:00
|
|
|
|
2010-09-06 11:05:43 +08:00
|
|
|
int nilfs_mdt_setup_shadow_map(struct inode *inode,
|
|
|
|
struct nilfs_shadow_map *shadow);
|
|
|
|
int nilfs_mdt_save_to_shadow_map(struct inode *inode);
|
|
|
|
void nilfs_mdt_restore_from_shadow_map(struct inode *inode);
|
|
|
|
void nilfs_mdt_clear_shadow_map(struct inode *inode);
|
2010-08-31 10:40:34 +08:00
|
|
|
int nilfs_mdt_freeze_buffer(struct inode *inode, struct buffer_head *bh);
|
|
|
|
struct buffer_head *nilfs_mdt_get_frozen_buffer(struct inode *inode,
|
|
|
|
struct buffer_head *bh);
|
2009-04-07 10:01:28 +08:00
|
|
|
|
|
|
|
static inline void nilfs_mdt_mark_dirty(struct inode *inode)
|
|
|
|
{
|
|
|
|
if (!test_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state))
|
|
|
|
set_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void nilfs_mdt_clear_dirty(struct inode *inode)
|
|
|
|
{
|
|
|
|
clear_bit(NILFS_I_DIRTY, &NILFS_I(inode)->i_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline __u64 nilfs_mdt_cno(struct inode *inode)
|
|
|
|
{
|
2011-05-05 11:56:51 +08:00
|
|
|
return ((struct the_nilfs *)inode->i_sb->s_fs_info)->ns_cno;
|
2009-04-07 10:01:28 +08:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:46:31 +08:00
|
|
|
static inline spinlock_t *
|
|
|
|
nilfs_mdt_bgl_lock(struct inode *inode, unsigned int block_group)
|
|
|
|
{
|
|
|
|
return bgl_lock_ptr(NILFS_MDT(inode)->mi_bgl, block_group);
|
|
|
|
}
|
2009-04-07 10:01:28 +08:00
|
|
|
|
|
|
|
#endif /* _NILFS_MDT_H */
|