Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.13-rc5 187 lines 5.0 kB view raw
1/* 2 * Copyright (c) 2008-2010, 2013 Dave Chinner 3 * All Rights Reserved. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it would be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18#include "xfs.h" 19#include "xfs_fs.h" 20#include "xfs_shared.h" 21#include "xfs_log_format.h" 22#include "xfs_trans_resv.h" 23#include "xfs_bit.h" 24#include "xfs_sb.h" 25#include "xfs_ag.h" 26#include "xfs_mount.h" 27#include "xfs_trans.h" 28#include "xfs_trans_priv.h" 29#include "xfs_error.h" 30#include "xfs_icreate_item.h" 31 32kmem_zone_t *xfs_icreate_zone; /* inode create item zone */ 33 34static inline struct xfs_icreate_item *ICR_ITEM(struct xfs_log_item *lip) 35{ 36 return container_of(lip, struct xfs_icreate_item, ic_item); 37} 38 39/* 40 * This returns the number of iovecs needed to log the given inode item. 41 * 42 * We only need one iovec for the icreate log structure. 43 */ 44STATIC void 45xfs_icreate_item_size( 46 struct xfs_log_item *lip, 47 int *nvecs, 48 int *nbytes) 49{ 50 *nvecs += 1; 51 *nbytes += sizeof(struct xfs_icreate_log); 52} 53 54/* 55 * This is called to fill in the vector of log iovecs for the 56 * given inode create log item. 57 */ 58STATIC void 59xfs_icreate_item_format( 60 struct xfs_log_item *lip, 61 struct xfs_log_iovec *log_vector) 62{ 63 struct xfs_icreate_item *icp = ICR_ITEM(lip); 64 65 log_vector->i_addr = (xfs_caddr_t)&icp->ic_format; 66 log_vector->i_len = sizeof(struct xfs_icreate_log); 67 log_vector->i_type = XLOG_REG_TYPE_ICREATE; 68} 69 70 71/* Pinning has no meaning for the create item, so just return. */ 72STATIC void 73xfs_icreate_item_pin( 74 struct xfs_log_item *lip) 75{ 76} 77 78 79/* pinning has no meaning for the create item, so just return. */ 80STATIC void 81xfs_icreate_item_unpin( 82 struct xfs_log_item *lip, 83 int remove) 84{ 85} 86 87STATIC void 88xfs_icreate_item_unlock( 89 struct xfs_log_item *lip) 90{ 91 struct xfs_icreate_item *icp = ICR_ITEM(lip); 92 93 if (icp->ic_item.li_flags & XFS_LI_ABORTED) 94 kmem_zone_free(xfs_icreate_zone, icp); 95 return; 96} 97 98/* 99 * Because we have ordered buffers being tracked in the AIL for the inode 100 * creation, we don't need the create item after this. Hence we can free 101 * the log item and return -1 to tell the caller we're done with the item. 102 */ 103STATIC xfs_lsn_t 104xfs_icreate_item_committed( 105 struct xfs_log_item *lip, 106 xfs_lsn_t lsn) 107{ 108 struct xfs_icreate_item *icp = ICR_ITEM(lip); 109 110 kmem_zone_free(xfs_icreate_zone, icp); 111 return (xfs_lsn_t)-1; 112} 113 114/* item can never get into the AIL */ 115STATIC uint 116xfs_icreate_item_push( 117 struct xfs_log_item *lip, 118 struct list_head *buffer_list) 119{ 120 ASSERT(0); 121 return XFS_ITEM_SUCCESS; 122} 123 124/* Ordered buffers do the dependency tracking here, so this does nothing. */ 125STATIC void 126xfs_icreate_item_committing( 127 struct xfs_log_item *lip, 128 xfs_lsn_t lsn) 129{ 130} 131 132/* 133 * This is the ops vector shared by all buf log items. 134 */ 135static struct xfs_item_ops xfs_icreate_item_ops = { 136 .iop_size = xfs_icreate_item_size, 137 .iop_format = xfs_icreate_item_format, 138 .iop_pin = xfs_icreate_item_pin, 139 .iop_unpin = xfs_icreate_item_unpin, 140 .iop_push = xfs_icreate_item_push, 141 .iop_unlock = xfs_icreate_item_unlock, 142 .iop_committed = xfs_icreate_item_committed, 143 .iop_committing = xfs_icreate_item_committing, 144}; 145 146 147/* 148 * Initialize the inode log item for a newly allocated (in-core) inode. 149 * 150 * Inode extents can only reside within an AG. Hence specify the starting 151 * block for the inode chunk by offset within an AG as well as the 152 * length of the allocated extent. 153 * 154 * This joins the item to the transaction and marks it dirty so 155 * that we don't need a separate call to do this, nor does the 156 * caller need to know anything about the icreate item. 157 */ 158void 159xfs_icreate_log( 160 struct xfs_trans *tp, 161 xfs_agnumber_t agno, 162 xfs_agblock_t agbno, 163 unsigned int count, 164 unsigned int inode_size, 165 xfs_agblock_t length, 166 unsigned int generation) 167{ 168 struct xfs_icreate_item *icp; 169 170 icp = kmem_zone_zalloc(xfs_icreate_zone, KM_SLEEP); 171 172 xfs_log_item_init(tp->t_mountp, &icp->ic_item, XFS_LI_ICREATE, 173 &xfs_icreate_item_ops); 174 175 icp->ic_format.icl_type = XFS_LI_ICREATE; 176 icp->ic_format.icl_size = 1; /* single vector */ 177 icp->ic_format.icl_ag = cpu_to_be32(agno); 178 icp->ic_format.icl_agbno = cpu_to_be32(agbno); 179 icp->ic_format.icl_count = cpu_to_be32(count); 180 icp->ic_format.icl_isize = cpu_to_be32(inode_size); 181 icp->ic_format.icl_length = cpu_to_be32(length); 182 icp->ic_format.icl_gen = cpu_to_be32(generation); 183 184 xfs_trans_add_item(tp, &icp->ic_item); 185 tp->t_flags |= XFS_TRANS_DIRTY; 186 icp->ic_item.li_desc->lid_flags |= XFS_LID_DIRTY; 187}