[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Cluster-devel] [PATCH] gfs2-utils: Remove unused exported functions



Hi,

ACK,

Steve.

On Wed, 2012-07-04 at 16:30 +0100, Andrew Price wrote:
> These symbols are now unused within the gfs2-utils tree:
> 
> $ findunused.sh | grep -v '^group/'
> gfs2/libgfs2/libgfs2.h:712        find_debugfs_mount
> gfs2/libgfs2/misc.c:314           find_debugfs_mount
> gfs2/libgfs2/libgfs2.h:395        gfs2_bitcount
> gfs2/libgfs2/fs_bits.c:109        gfs2_bitcount
> gfs2/libgfs2/libgfs2.h:835        gfs2_dirent_print
> gfs2/libgfs2/ondisk.c:418         gfs2_dirent_print
> gfs2/libgfs2/libgfs2.h:810        gfs2_ea_header_out
> gfs2/libgfs2/ondisk.c:481         gfs2_ea_header_out
> gfs2/libgfs2/fs_ops.c:1371        init_gfs_dinode
> gfs2/libgfs2/libgfs2.h:451        init_gfs_dinode
> gfs2/libgfs2/libgfs2.h:713        mp2fsname
> gfs2/libgfs2/misc.c:365           mp2fsname
> gfs2/libgfs2/libgfs2.h:705        get_sysfs
> gfs2/libgfs2/misc.c:273           get_sysfs
> 
> So it's safe to remove them. The idea is to simplify libgfs2 for now but
> if these are required in future they can be brought back.
> 
> Signed-off-by: Andrew Price <anprice redhat com>
> ---
>  gfs2/libgfs2/fs_bits.c |   32 -------------
>  gfs2/libgfs2/fs_ops.c  |    8 ----
>  gfs2/libgfs2/libgfs2.h |   12 -----
>  gfs2/libgfs2/misc.c    |  124 ------------------------------------------------
>  gfs2/libgfs2/ondisk.c  |   28 -----------
>  5 files changed, 204 deletions(-)
> 
> diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
> index d3ac048..5eeb920 100644
> --- a/gfs2/libgfs2/fs_bits.c
> +++ b/gfs2/libgfs2/fs_bits.c
> @@ -98,38 +98,6 @@ unsigned long gfs2_bitfit(const unsigned char *buf, const unsigned int len,
>  	return (((const unsigned char *)ptr - buf) * GFS2_NBBY) + bit;
>  }
>  
> -/**
> - * fs_bitcount - count the number of bits in a certain state
> - * @buffer: the buffer that holds the bitmaps
> - * @buflen: the length (in bytes) of the buffer
> - * @state: the state of the block we're looking for
> - *
> - * Returns: The number of bits
> - */
> -uint32_t gfs2_bitcount(unsigned char *buffer, unsigned int buflen,
> -		       unsigned char state)
> -{
> -	unsigned char *byte, *end;
> -	unsigned int bit;
> -	uint32_t count = 0;
> -
> -	byte = buffer;
> -	bit = 0;
> -	end = buffer + buflen;
> -
> -	while (byte < end){
> -		if (((*byte >> bit) & GFS2_BIT_MASK) == state)
> -			count++;
> -
> -		bit += GFS2_BIT_SIZE;
> -		if (bit >= 8){
> -			bit = 0;
> -			byte++;
> -		}
> -	}
> -	return count;
> -}
> -
>  /*
>   * check_range - check if blkno is within FS limits
>   * @sdp: super block
> diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
> index 470916c..9409332 100644
> --- a/gfs2/libgfs2/fs_ops.c
> +++ b/gfs2/libgfs2/fs_ops.c
> @@ -1368,14 +1368,6 @@ struct gfs2_buffer_head *init_dinode(struct gfs2_sbd *sdp,
>  	return __init_dinode(sdp, inum, mode, flags, parent, 0);
>  }
>  
> -struct gfs2_buffer_head *init_gfs_dinode(struct gfs2_sbd *sdp,
> -					 struct gfs2_inum *inum,
> -					 unsigned int mode, uint32_t flags,
> -					 struct gfs2_inum *parent)
> -{
> -	return __init_dinode(sdp, inum, mode, flags, parent, 1);
> -}
> -
>  static struct gfs2_inode *__createi(struct gfs2_inode *dip,
>  				    const char *filename, unsigned int mode,
>  				    uint32_t flags, int if_gfs1)
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 2fc47de..09f0b1d 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -392,8 +392,6 @@ extern void fix_device_geometry(struct gfs2_sbd *sdp);
>  #define BFITNOENT (0xFFFFFFFF)
>  
>  /* functions with blk #'s that are buffer relative */
> -extern uint32_t gfs2_bitcount(unsigned char *buffer, unsigned int buflen,
> -			      unsigned char state);
>  extern unsigned long gfs2_bitfit(const unsigned char *buffer,
>  				 const unsigned int buflen,
>  				 unsigned long goal, unsigned char old_state);
> @@ -448,11 +446,6 @@ extern struct gfs2_buffer_head *init_dinode(struct gfs2_sbd *sdp,
>  					    struct gfs2_inum *inum,
>  					    unsigned int mode, uint32_t flags,
>  					    struct gfs2_inum *parent);
> -extern struct gfs2_buffer_head *init_gfs_dinode(struct gfs2_sbd *sdp,
> -						struct gfs2_inum *inum,
> -						unsigned int mode,
> -						uint32_t flags,
> -						struct gfs2_inum *parent);
>  extern struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename,
>  				  unsigned int mode, uint32_t flags);
>  extern struct gfs2_inode *gfs_createi(struct gfs2_inode *dip,
> @@ -709,9 +702,6 @@ extern int dir_exists(const char *dir);
>  extern int check_for_gfs2(struct gfs2_sbd *sdp);
>  extern int mount_gfs2_meta(struct gfs2_sbd *sdp);
>  extern void cleanup_metafs(struct gfs2_sbd *sdp);
> -extern char *find_debugfs_mount(void);
> -extern char *mp2fsname(char *mp);
> -extern char *get_sysfs(const char *fsname, const char *filename);
>  extern int set_sysfs(const char *fsname, const char *filename, const char *val);
>  extern int is_fsname(char *name);
>  extern void get_random_bytes(void *buf, int nbytes);
> @@ -807,7 +797,6 @@ extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
>  extern void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh);
>  extern void gfs2_leaf_out(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh);
>  extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf);
> -extern void gfs2_ea_header_out(struct gfs2_ea_header *ea, char *buf);
>  extern void gfs2_log_header_in(struct gfs2_log_header *lh,
>  			       struct gfs2_buffer_head *bh);
>  extern void gfs2_log_header_out(struct gfs2_log_header *lh,
> @@ -832,7 +821,6 @@ extern void gfs2_rindex_print(struct gfs2_rindex *ri);
>  extern void gfs2_rgrp_print(struct gfs2_rgrp *rg);
>  extern void gfs2_quota_print(struct gfs2_quota *qu);
>  extern void gfs2_dinode_print(struct gfs2_dinode *di);
> -extern void gfs2_dirent_print(struct gfs2_dirent *de, char *name);
>  extern void gfs2_leaf_print(struct gfs2_leaf *lf);
>  extern void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name);
>  extern void gfs2_log_header_print(struct gfs2_log_header *lh);
> diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
> index 13ef972..a68da4a 100644
> --- a/gfs2/libgfs2/misc.c
> +++ b/gfs2/libgfs2/misc.c
> @@ -248,42 +248,6 @@ void cleanup_metafs(struct gfs2_sbd *sdp)
>  		rmdir(sdp->metafs_path);
>  }
>  
> -static char *__get_sysfs(const char *fsname, const char *filename)
> -{
> -	char path[PATH_MAX];
> -	int fd, rv;
> -
> -	memset(path, 0, PATH_MAX);
> -	memset(sysfs_buf, 0, PAGE_SIZE);
> -	snprintf(path, PATH_MAX - 1, "%s/%s/%s", SYS_BASE, fsname, filename);
> -
> -	fd = open(path, O_RDONLY);
> -	if (fd < 0)
> -		return NULL;
> -	rv = read(fd, sysfs_buf, PAGE_SIZE);
> -	if (rv < 0) {
> -		close(fd);
> -		return NULL;
> -	}
> -
> -	close(fd);
> -	return sysfs_buf;
> -}
> -
> -char *get_sysfs(const char *fsname, const char *filename)
> -{
> -	char *s;
> -	char *p;
> -
> -	s = __get_sysfs(fsname, filename);
> -	if (!s)
> -		return NULL;
> -	p = strchr(s, '\n');
> -	if (p)
> -		*p = '\0';
> -	return sysfs_buf;
> -}
> -
>  int set_sysfs(const char *fsname, const char *filename, const char *val)
>  {
>  	char path[PATH_MAX];
> @@ -311,94 +275,6 @@ int set_sysfs(const char *fsname, const char *filename, const char *val)
>  	return 0;
>  }
>  
> -char *find_debugfs_mount(void)
> -{
> -	FILE *file;
> -	char line[PATH_MAX];
> -	char device[PATH_MAX], type[PATH_MAX];
> -	char *path;
> -
> -	file = fopen("/proc/mounts", "rt");
> -	if (!file)
> -		return NULL;
> -
> -	path = malloc(PATH_MAX);
> -	if (!path) {
> -		fclose(file);
> -		return NULL;
> -	}
> -	while (fgets(line, PATH_MAX, file)) {
> -
> -		if (sscanf(line, "%s %s %s", device, path, type) != 3)
> -			continue;
> -		if (!strcmp(type, "debugfs")) {
> -			fclose(file);
> -			return path;
> -		}
> -	}
> -
> -	free(path);
> -	fclose(file);
> -	return NULL;
> -}
> -
> -/**
> - * mp2fsname - Find the name for a filesystem given its mountpoint
> - *
> - * We do this by iterating through gfs2 dirs in /sys/fs/gfs2/ looking for
> - * one where the "id" attribute matches the device id returned by stat for
> - * the mount point.  The reason we go through all this is simple: the
> - * kernel's sysfs is named after the VFS s_id, not the device name.
> - * So it's perfectly legal to do something like this to simulate user
> - * conditions without the proper hardware:
> - *    # rm /dev/sdb1
> - *    # mkdir /dev/cciss
> - *    # mknod /dev/cciss/c0d0p1 b 8 17
> - *    # mount -tgfs2 /dev/cciss/c0d0p1 /mnt/gfs2
> - *    # gfs2_tool gettune /mnt/gfs2
> - * In this example the tuning variables are in a directory named after the
> - * VFS s_id, which in this case would be /sys/fs/gfs2/sdb1/
> - *
> - * Returns: the fsname
> - */
> -
> -char *mp2fsname(char *mp)
> -{
> -	char device_id[PATH_MAX], *fsname = NULL;
> -	struct stat statbuf;
> -	DIR *d;
> -	struct dirent *de;
> -	char *id;
> -
> -	if (stat(mp, &statbuf))
> -		return NULL;
> -
> -	memset(device_id, 0, sizeof(device_id));
> -	sprintf(device_id, "%i:%i", major(statbuf.st_dev),
> -		minor(statbuf.st_dev));
> -
> -	d = opendir(SYS_BASE);
> -	if (!d)
> -		return NULL;
> -
> -	while ((de = readdir(d))) {
> -		if (de->d_name[0] == '.')
> -			continue;
> -
> -		id = get_sysfs(de->d_name, "id");
> -		if (!id)
> -			continue;
> -		if (strcmp(id, device_id) == 0) {
> -			fsname = strdup(de->d_name);
> -			break;
> -		}
> -	}
> -
> -	closedir(d);
> -
> -	return fsname;
> -}
> -
>  /*
>   * get_random_bytes - Generate a series of random bytes using /dev/urandom.
>   *
> diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
> index 73b2b0f..301d92d 100644
> --- a/gfs2/libgfs2/ondisk.c
> +++ b/gfs2/libgfs2/ondisk.c
> @@ -415,21 +415,6 @@ void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
>  	memset(str->__pad, 0, sizeof(str->__pad));
>  }
>  
> -void gfs2_dirent_print(struct gfs2_dirent *de, char *name)
> -{
> -	char buf[GFS2_FNAMESIZE + 1];
> -
> -	gfs2_inum_print(&de->de_inum);
> -	pv(de, de_hash, "0x%.8X", NULL);
> -	pv(de, de_rec_len, "%u", "0x%x");
> -	pv(de, de_name_len, "%u", "0x%x");
> -	pv(de, de_type, "%u", "0x%x");
> -
> -	memset(buf, 0, GFS2_FNAMESIZE + 1);
> -	memcpy(buf, name, de->de_name_len);
> -	print_it("  name", "%s", NULL, buf);
> -}
> -
>  void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
>  {
>  	struct gfs2_leaf *str = (struct gfs2_leaf *)bh->b_data;
> @@ -478,19 +463,6 @@ void gfs2_ea_header_in(struct gfs2_ea_header *ea, char *buf)
>  	ea->ea_num_ptrs = str->ea_num_ptrs;
>  }
>  
> -void gfs2_ea_header_out(struct gfs2_ea_header *ea, char *buf)
> -{
> -	struct gfs2_ea_header *str = (struct gfs2_ea_header *)buf;
> -
> -	CPOUT_32(ea, str, ea_rec_len);
> -	CPOUT_32(ea, str, ea_data_len);
> -	str->ea_name_len = ea->ea_name_len;
> -	str->ea_type = ea->ea_type;
> -	str->ea_flags = ea->ea_flags;
> -	str->ea_num_ptrs = ea->ea_num_ptrs;
> -	str->__pad = 0;
> -}
> -
>  void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name)
>  {
>  	char buf[GFS2_EA_MAX_NAME_LEN + 1];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]