X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fllverfs.c;h=87c9a9c28db08b4b226f3ed894ec0ec94f167af1;hb=35b3a429d1915ec147f01a42c4ec0526b887d1c7;hp=0042e44f84fbfba99bbf1d393c8461a25e1f5d71;hpb=f2a9374170e4522b9d2ac3b7096cf2912339d480;p=fs%2Flustre-release.git diff --git a/lustre/utils/llverfs.c b/lustre/utils/llverfs.c index 0042e44..87c9a9c 100644 --- a/lustre/utils/llverfs.c +++ b/lustre/utils/llverfs.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,8 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011 Whamcloud, Inc. - * + * Copyright (c) 2011, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -530,6 +527,7 @@ static int dir_write(char *chunk_buf, size_t chunksize, struct timeval start_time; unsigned long long total_bytes; unsigned long long curr_bytes = 0; + int rc = 0; #ifdef HAVE_EXT2FS_EXT2FS_H if (!full && fsetflags(testdir, EXT2_TOPDIR_FL)) @@ -548,7 +546,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, fflush(countfile) != 0) { fprintf(stderr, "\n%s: writing %s failed :%s\n", progname, filecount, strerror(errno)); - return 6; + rc = 6; + goto out; } /* calculate total bytes that need to be written */ @@ -556,7 +555,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, if (total_bytes <= 0) { fprintf(stderr, "\n%s: unable to calculate total bytes\n", progname); - return 7; + rc = 7; + goto out; } if (!full && (dir_num != 0)) @@ -578,7 +578,8 @@ static int dir_write(char *chunk_buf, size_t chunksize, fprintf(stderr, "\n%s: mkdir %s : %s\n", progname, tempdir, strerror(errno)); - return 1; + rc = 1; + goto out; } } dir_num++; @@ -603,8 +604,10 @@ static int dir_write(char *chunk_buf, size_t chunksize, time_st, inode_st, tempfile); close(fd); if (ret < 0) { - if (ret != -ENOSPC) - return 1; + if (ret != -ENOSPC) { + rc = 1; + goto out; + } curr_bytes = total_bytes; break; } @@ -621,7 +624,6 @@ static int dir_write(char *chunk_buf, size_t chunksize, progname, filecount, strerror(errno)); } } - fclose(countfile); if (verbose) { verbose++; @@ -631,7 +633,10 @@ static int dir_write(char *chunk_buf, size_t chunksize, verbose--; } - return 0; +out: + fclose(countfile); + + return rc; } /* @@ -864,7 +869,8 @@ guess: fprintf(stderr, "Memory allocation failed for chunk_buf\n"); return 4; } - sprintf(filecount, "%s/%s.filecount", testdir, progname); + snprintf(filecount, sizeof(filecount), "%s/%s.filecount", + testdir, progname); if (writeoption) { (void)mkdir(testdir, dirmode);