GFS2: Add directory addition info structure
From 3c1c0ae1db74b1f3e606f42158b5dadd89105c1f Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Mon, 6 Jan 2014 11:28:41 +0000
Subject: GFS2: Add directory addition info structure
The intent is that this structure will hold the information required when adding entries to a directory (linking). To start with, it will contain only the number of blocks which are required to link the new entry into the directory. The current calculation returns either 0 or the maximim number of blocks that can ever be requested by such a transaction.
The intent is that in a later patch, we can update the dir code to calculate this value more accurately. In addition further patches will also add further fields to the new structure to increase its utility.
In addition this patch fixes a bug where the link used during inode creation was adding requesting too many blocks in some cases. This is harmless unless the fs is close to being full.
fs/gfs2/dir.c +9 -3
@@ -2017,18 +2017,24 @@ out:* gfs2_diradd_alloc_required - find if adding entry will require an allocation * @ip: the file being written to * @filname: the filename that's going to be added +* @da: The structure to return dir alloc info * -* Returns: 1 if alloc required, 0 if not, -ve on error +* Returns: 0 if ok, -ve on error */ -int gfs2_diradd_alloc_required (struct inode *inode,const struct qstr *name) +int gfs2_diradd_alloc_required (struct inode *inode,const struct qstr *name, +struct gfs2_diradd *da) { +struct gfs2_sbd *sdp =GFS2_SB (inode);struct gfs2_dirent *dent;struct buffer_head *bh; + da->nr_blocks =0 ; + dent =gfs2_dirent_search (inode, name, gfs2_dirent_find_space, &bh);if (!dent) { -return 1 ; + da->nr_blocks = sdp->sd_max_dirres; +return 0 ; }if (IS_ERR (dent))return PTR_ERR (dent);
fs/gfs2/dir.h +6 -1
@@ -17,6 +17,10 @@ struct inode;struct gfs2_inode ;struct gfs2_inum ; +struct gfs2_diradd { +unsigned nr_blocks; +}; +extern struct inode *gfs2_dir_search (struct inode *dir,const struct qstr *filename,bool fail_on_exist);
@@ -33,7 +37,8 @@ extern int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,extern int gfs2_dir_exhash_dealloc (struct gfs2_inode *dip);extern int gfs2_diradd_alloc_required (struct inode *dir, -const struct qstr *filename); +const struct qstr *filename, +struct gfs2_diradd *da);extern int gfs2_dir_get_new_buffer (struct gfs2_inode *ip,u64 block,struct buffer_head **bhp);extern void gfs2_dir_hash_inval (struct gfs2_inode *ip);
fs/gfs2/inode.c +28 -29
147 lines not on this page · raw message
Signature · 1 line
1.8.3.1