1ccd979bdSMark Fasheh /* -*- mode: c; c-basic-offset: 8; -*- 2ccd979bdSMark Fasheh * vim: noexpandtab sw=8 ts=8 sts=0: 3ccd979bdSMark Fasheh * 4ccd979bdSMark Fasheh * extent_map.h 5ccd979bdSMark Fasheh * 6ccd979bdSMark Fasheh * In-memory file extent mappings for OCFS2. 7ccd979bdSMark Fasheh * 8ccd979bdSMark Fasheh * Copyright (C) 2004 Oracle. All rights reserved. 9ccd979bdSMark Fasheh * 10ccd979bdSMark Fasheh * This program is free software; you can redistribute it and/or 11ccd979bdSMark Fasheh * modify it under the terms of the GNU General Public 12ccd979bdSMark Fasheh * License, version 2, as published by the Free Software Foundation. 13ccd979bdSMark Fasheh * 14ccd979bdSMark Fasheh * This program is distributed in the hope that it will be useful, 15ccd979bdSMark Fasheh * but WITHOUT ANY WARRANTY; without even the implied warranty of 16ccd979bdSMark Fasheh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17ccd979bdSMark Fasheh * General Public License for more details. 18ccd979bdSMark Fasheh * 19ccd979bdSMark Fasheh * You should have received a copy of the GNU General Public 20ccd979bdSMark Fasheh * License along with this program; if not, write to the 21ccd979bdSMark Fasheh * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22ccd979bdSMark Fasheh * Boston, MA 021110-1307, USA. 23ccd979bdSMark Fasheh */ 24ccd979bdSMark Fasheh 25ccd979bdSMark Fasheh #ifndef _EXTENT_MAP_H 26ccd979bdSMark Fasheh #define _EXTENT_MAP_H 27ccd979bdSMark Fasheh 2883418978SMark Fasheh struct ocfs2_extent_map_item { 2983418978SMark Fasheh unsigned int ei_cpos; 3083418978SMark Fasheh unsigned int ei_phys; 3183418978SMark Fasheh unsigned int ei_clusters; 3283418978SMark Fasheh unsigned int ei_flags; 3383418978SMark Fasheh 3483418978SMark Fasheh struct list_head ei_list; 3583418978SMark Fasheh }; 3683418978SMark Fasheh 3783418978SMark Fasheh #define OCFS2_MAX_EXTENT_MAP_ITEMS 3 3883418978SMark Fasheh struct ocfs2_extent_map { 3983418978SMark Fasheh unsigned int em_num_items; 4083418978SMark Fasheh struct list_head em_list; 4183418978SMark Fasheh }; 4283418978SMark Fasheh 4383418978SMark Fasheh void ocfs2_extent_map_init(struct inode *inode); 4483418978SMark Fasheh void ocfs2_extent_map_trunc(struct inode *inode, unsigned int cluster); 4583418978SMark Fasheh void ocfs2_extent_map_insert_rec(struct inode *inode, 4683418978SMark Fasheh struct ocfs2_extent_rec *rec); 4783418978SMark Fasheh 489517bac6SMark Fasheh int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster, 4949cb8d2dSMark Fasheh u32 *num_clusters, unsigned int *extent_flags); 50363041a5SMark Fasheh int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, 514f902c37SMark Fasheh u64 *ret_count, unsigned int *extent_flags); 52ccd979bdSMark Fasheh 5300dc417fSMark Fasheh int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 5400dc417fSMark Fasheh u64 map_start, u64 map_len); 5500dc417fSMark Fasheh 56ac604d3cSGang He int ocfs2_overwrite_io(struct inode *inode, struct buffer_head *di_bh, 57ac604d3cSGang He u64 map_start, u64 map_len); 58ac604d3cSGang He 5993862d5eSSunil Mushran int ocfs2_seek_data_hole_offset(struct file *file, loff_t *offset, int origin); 6093862d5eSSunil Mushran 61f56654c4STao Ma int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster, 62f56654c4STao Ma u32 *p_cluster, u32 *num_clusters, 631061f9c1STao Ma struct ocfs2_extent_list *el, 641061f9c1STao Ma unsigned int *extent_flags); 65f56654c4STao Ma 66a8549fb5SJoel Becker int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, 67a8549fb5SJoel Becker struct buffer_head *bhs[], int flags, 68a8549fb5SJoel Becker int (*validate)(struct super_block *sb, 69a8549fb5SJoel Becker struct buffer_head *bh)); 70e73a819dSTao Ma int ocfs2_figure_hole_clusters(struct ocfs2_caching_info *ci, 71e73a819dSTao Ma struct ocfs2_extent_list *el, 72e73a819dSTao Ma struct buffer_head *eb_bh, 73e73a819dSTao Ma u32 v_cluster, 74e73a819dSTao Ma u32 *num_clusters); 75a8549fb5SJoel Becker static inline int ocfs2_read_virt_block(struct inode *inode, u64 v_block, 76a8549fb5SJoel Becker struct buffer_head **bh, 77a8549fb5SJoel Becker int (*validate)(struct super_block *sb, 78a8549fb5SJoel Becker struct buffer_head *bh)) 79a8549fb5SJoel Becker { 80a8549fb5SJoel Becker int status = 0; 81a8549fb5SJoel Becker 82a8549fb5SJoel Becker if (bh == NULL) { 83a8549fb5SJoel Becker printk("ocfs2: bh == NULL\n"); 84a8549fb5SJoel Becker status = -EINVAL; 85a8549fb5SJoel Becker goto bail; 86a8549fb5SJoel Becker } 87a8549fb5SJoel Becker 88a8549fb5SJoel Becker status = ocfs2_read_virt_blocks(inode, v_block, 1, bh, 0, validate); 89a8549fb5SJoel Becker 90a8549fb5SJoel Becker bail: 91a8549fb5SJoel Becker return status; 92a8549fb5SJoel Becker } 93a8549fb5SJoel Becker 94a8549fb5SJoel Becker 95ccd979bdSMark Fasheh #endif /* _EXTENT_MAP_H */ 96