Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-9936

ldiskfs_write_ldd() calls fsync(filep->_fileno) but doesn't fflush() flip first

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      In ldiskfs_write_ldd():

       270         num = fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
       271         if (num < 1 && ferror(filep)) {
       272                 fprintf(stderr, "%s: Unable to write to file (%s): %s\n",
       273                         progname, filepnm, strerror(errno));
       274                 fclose(filep);
       275                 goto out_umnt;
       276         }
       277         fsync(filep->_fileno);
       278         fclose(filep);
       

      Calling fsync() without first calling fflush() is ineffective since there will likely still be unwritten data in the userspace buffer.

      Also we should use fileno(filp) instead of accessing filp->_fileno.

      We should check the returns of fflush(), fsync(), and fclose() for failure. Since an error is more likely to be reported there than from fwrite().

      Attachments

        Activity

          People

            wc-triage WC Triage
            jhammond John Hammond
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: