| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | [RFD] xfs_fsr: Doubts related to xfs_fsr code |
| From: | Somdeep Dey <somdeepdey10@xxxxxxxxx> |
| Date: | Sat, 13 Sep 2014 22:37:53 +0530 |
| Delivered-to: | xfs@xxxxxxxxxxx |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=qJObt37yk5W5+h1QCojTwF51G5viJt86RFbrMefQw0A=; b=0xnVRoChnrOEIGWYQJkIRrEJtNnMizdiTdYJ4gZnhP3W4t76DzNMtbTjqctv7TWQMh BdZBbec+1js+IkfsT/u4Fqy4uLnTIzn6Df8umWajd2CIc/qTf9Zx+h94+ssrcaRyVPPn WI9njwPqonN+KdcJpHUCL7AtBdPQ7HRaiWpfa5SQ3+N0oGmzKgLxryiTjremLvV6q7he 3XjoUXWl8wBRW2zY4DeD/qKrDrjtFFmjzGMK3migxhjnNhHBmXVMNJdV4iSUGsbncHFm iUmmiBV8m/Aq9knPwGGAY6zV2TyWs+PIFoBeueHyEg5mQ2UXDjrHiR9/K7Tujtyo7xy7 hRsg== |
|
Hi, While studying the code and attempting to understand it, we have come up against certain doubts that have us in a slight fix. We've included the concerned Âsections of the code below, along with our specific problem in each of these Âsections. A little pointer in the right direction would be of great help. (Source file : fsr_xfs_fsr.c) ****** Doubt number 1 ****** (line 331 onwards) int main() if (optind < argc) // If the command line input contains the XFS //filesystem name / file on which xfs_fsr needs to be run on { for (; optind < argc; optind++) { argname = argv[optind]; // save target which can be file or filesystem if (lstat64(argname, &sb) < 0) { /* This system call returns a stat64 structure, and thus sets              * all fields in it. * On success, zero is returned. ÂOn error, -1 is returned,         * and Âerrno Âis set appropriately. */ fprintf(stderr, _("%s: could not stat: %s: %s\n"), progname, argname, strerror(errno)); continue; } // POSIX macros are defined to check the file type using the st_mode field if (S_ISLNK(sb.st_mode)) // Check if path(argname) is a //symbolic link, if so link will be stat-ed and not file {// Hence Âwe run stat64() and save the obtained stat structure struct stat64 sb2; if (stat64(argname, &sb2) == 0 && (S_ISBLK(sb2.st_mode) ||    S_ISCHR(sb2.st_mode))) sb = sb2; // check if stat is a success and //if argname(path) is block device ? OR is character device? } ________________________________________________________________________________ We understand that lstat64() and stat64() are used to see if target Â(file/filesystem) can be stated and if yes then the structure is saved. But we couldnât exactly understand its use and why both functions are used separately. Usually the error could not stat: filename : is followed by Permission denied. ÂIs this related to the root permissions i.e. accessibility ? ****** Doubt number 2 ****** (line 184 onwards) static char * find_mountpoint(char *mtab, char *argname, struct stat64 *sb) while ((t = getmntent(mtabp))) { if (S_ISDIR(sb->st_mode)) { /* mount point */ if (stat64(t->mnt_dir, &ms) < 0) continue; if (sb->st_ino != ms.st_ino) continue; if (sb->st_dev != ms.st_dev) continue; if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0) continue; } else { /* device */ struct stat64 sb2; if (stat64(t->mnt_fsname, &ms) < 0) continue; if (sb->st_rdev != ms.st_rdev) continue; if (strcmp(t->mnt_type, MNTTYPE_XFS) != 0) continue; /* * Make sure the mount point given by mtab is accessible * before using it. */ if (stat64(t->mnt_dir, &sb2) < 0) continue; } ________________________________________________________________________________ We just wanted to confirm if the basic working of the function is 1) To obtain a mount table pointer to the mount table (/etc/mtab/ or /proc/mounts). 2) ÂFor each entry in the mount table check if it is a directory or device and after Âperforming various comparisons (checks) â (could you please elaborate on the checks  performed), this function returns a pointer to the entry. ****** Doubt number 3 ****** (line 677 onwards) static int fsrfs(char *mntdir, xfs_ino_t startino, int targetrange) For the following __s32 buflenout; fshandlep = jdm_getfshandle( mntdir ); if ( ! fshandlep ) { fsrprintf(_("unable to get handle: %s: %s\n"),     Âmntdir, strerror( errno )); return -1; } ________________________________________________________________________________ We are a bit confused about what is exactly the file handle being returned Âby jdm_getfshandle(). Also what exactly is buflenout. Is it a structure field ? ________________________________________________________________________________ while ((ret = xfs_bulkstat(fsfd,&lastino, GRABSZ, &buf[0], &buflenout) == 0)) { xfs_bstat_t *p; xfs_bstat_t *endp; if (buflenout == 0) goto out0; /* Each loop through, defrag targetrange percent of the files */ count = (buflenout * targetrange) / 100; qsort((char *)buf, buflenout, sizeof(struct xfs_bstat), cmp); ________________________________________________________________________________ In the above code snippet we understand that the while loop will run for N(10) passes and defragment top 10% of the defragmented files. However we would appreciate if you could further explain the functions: (ret = xfs_bulkstat(fsfd,&lastino, GRABSZ, &buf[0], &buflenout) == 0) qsort((char *)buf, buflenout, sizeof(struct xfs_bstat), cmp); We know that the sort function will be used to sort extents based on size and then offset, but a bit more information on how it is exactly working will be really appreciated, as we believe that this sort() has some other purpose. ________________________________________________________________________________ For this mail we have listed only a limited number of doubts that we think are pressing. Based on further explanations that we might receive from you, we will send out another Âmail for the doubts that still linger. Regards, A-DRS. |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: unclean shutdown of usb hdd destroyed xfs partially, Carlos E. R. |
|---|---|
| Next by Date: | Re: [PATCH V3] xfs_io: add mremap command, Christoph Hellwig |
| Previous by Thread: | unclean shutdown of usb hdd destroyed xfs partially, Marko Weber|8000 |
| Next by Thread: | Re: [RFD] xfs_fsr: Doubts related to xfs_fsr code, Eric Sandeen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |