Activity log for bug #1244205

Date Who What changed Old value New value Message
2013-10-24 12:33:45 Hao-Ran Liu bug added bug
2013-10-24 12:35:12 Hao-Ran Liu bug task added cups (Ubuntu)
2013-10-24 12:38:58 Hao-Ran Liu description cupsd calls fsync() on /etc/subscriptions.conf.N every 14~15 minutes. This causes the hard disk to wake up soon after it spins down. Subscription renewal is from indicator-printers every 15 minutes. I think we don't need cupsdRemoveFile() to always overwrite data and do a fsync() for this file. Currently only Precise is confirmed to be affected. Saucy seems not having the same issue according to (http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/saucy/cups/saucy/view/head:/scheduler/file.c#L149) ---- cups: scheduler/file.c ---- int /* O - 0 on success, -1 on error */ cupsdCloseCreatedConfFile( cups_file_t *fp, /* I - File to close */ const char *filename) /* I - Filename */ { ... snprintf(newfile, sizeof(newfile), "%s.N", filename); snprintf(oldfile, sizeof(oldfile), "%s.O", filename); if ((cupsdRemoveFile(oldfile) && errno != ENOENT) || (rename(filename, oldfile) && errno != ENOENT) || rename(newfile, filename)) { cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to finalize \"%s\": %s", filename, strerror(errno)); return (-1); } return (0); } int /* O - 0 on success, -1 on error */ cupsdRemoveFile(const char *filename) /* I - File to remove */ { ... /* * Overwrite the file 7 times with 0xF6, 0x00, 0xFF, random, 0x00, 0xFF, * and more random data. */ memset(buffer, 0xF6, sizeof(buffer)); if (overwrite_data(fd, buffer, sizeof(buffer), (int)info.st_size)) { close(fd); return (-1); } ... } static int /* O - 0 on success, -1 on error */ overwrite_data(int fd, /* I - File descriptor */ const char *buffer, /* I - Buffer to write */ int bufsize, /* I - Size of buffer */ int filesize) /* I - Size of file */ { int bytes; /* Bytes to write/written */ /* * Start at the beginning of the file... */ if (lseek(fd, 0, SEEK_SET) < 0) return (-1); /* * Fill the file with the provided data... */ while (filesize > 0) { if (filesize > bufsize) bytes = bufsize; else bytes = filesize; if ((bytes = write(fd, buffer, bytes)) < 0) return (-1); filesize -= bytes; } /* * Force the changes to disk... */ return (fsync(fd)); } ---- indicator-printers-service.c ---- #define NOTIFY_LEASE_DURATION (15 * 60) int main (int argc, char *argv[]) { ... g_timeout_add_seconds (NOTIFY_LEASE_DURATION - 60, renew_subscription_timeout, &subscription_id); ... } ---- block_dump from the kernel ---- <7>[19935.646436] cupsd(1066): dirtied inode 15336755 (subscriptions.conf.N) on sda3 <7>[19935.646673] cupsd(1066): WRITE block 352753016 on sda3 (8 sectors) <7>[19935.646755] cupsd(1066): dirtied inode 15335603 (?) on sda3 <7>[19935.646763] cupsd(1066): dirtied inode 15335603 (?) on sda3 <7>[19935.646776] cupsd(1066): WRITE block 352701128 on sda3 (8 sectors) <7>[20774.607856] cupsd(1066): dirtied inode 15335603 (subscriptions.conf.N) on sda3 <7>[20774.608034] cupsd(1066): WRITE block 352862776 on sda3 (8 sectors) <7>[20774.608113] cupsd(1066): dirtied inode 15335607 (?) on sda3 <7>[20774.608120] cupsd(1066): dirtied inode 15335607 (?) on sda3 <7>[20774.608133] cupsd(1066): WRITE block 352753008 on sda3 (8 sectors) <7>[21613.569033] cupsd(1066): dirtied inode 15335607 (subscriptions.conf.N) on sda3 <7>[21613.569257] cupsd(1066): WRITE block 352753024 on sda3 (8 sectors) <7>[21613.569345] cupsd(1066): dirtied inode 15336755 (?) on sda3 <7>[21613.569353] cupsd(1066): dirtied inode 15336755 (?) on sda3 <7>[21613.569367] cupsd(1066): WRITE block 352753016 on sda3 (8 sectors) cupsd calls fsync() on /etc/subscriptions.conf.N every 14~15 minutes. This causes the hard disk to wake up soon after it spins down. Subscription renewal is from indicator-printers every 15 minutes. I think we don't need cupsdRemoveFile() to always overwrite data and do a fsync() for this file. Currently only Precise is confirmed to be affected. Saucy seems not having the same issue according to (http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/saucy/cups/saucy/view/head:/scheduler/file.c#L149) ---- block_dump from the kernel ---- <7>[19935.646436] cupsd(1066): dirtied inode 15336755 (subscriptions.conf.N) on sda3 <7>[19935.646673] cupsd(1066): WRITE block 352753016 on sda3 (8 sectors) <7>[19935.646755] cupsd(1066): dirtied inode 15335603 (?) on sda3 <7>[19935.646763] cupsd(1066): dirtied inode 15335603 (?) on sda3 <7>[19935.646776] cupsd(1066): WRITE block 352701128 on sda3 (8 sectors) <7>[20774.607856] cupsd(1066): dirtied inode 15335603 (subscriptions.conf.N) on sda3 <7>[20774.608034] cupsd(1066): WRITE block 352862776 on sda3 (8 sectors) <7>[20774.608113] cupsd(1066): dirtied inode 15335607 (?) on sda3 <7>[20774.608120] cupsd(1066): dirtied inode 15335607 (?) on sda3 <7>[20774.608133] cupsd(1066): WRITE block 352753008 on sda3 (8 sectors) <7>[21613.569033] cupsd(1066): dirtied inode 15335607 (subscriptions.conf.N) on sda3 <7>[21613.569257] cupsd(1066): WRITE block 352753024 on sda3 (8 sectors) <7>[21613.569345] cupsd(1066): dirtied inode 15336755 (?) on sda3 <7>[21613.569353] cupsd(1066): dirtied inode 15336755 (?) on sda3 <7>[21613.569367] cupsd(1066): WRITE block 352753016 on sda3 (8 sectors) ---- cups: scheduler/file.c ---- int /* O - 0 on success, -1 on error */ cupsdCloseCreatedConfFile(     cups_file_t *fp, /* I - File to close */     const char *filename) /* I - Filename */ { ...   snprintf(newfile, sizeof(newfile), "%s.N", filename);   snprintf(oldfile, sizeof(oldfile), "%s.O", filename);   if ((cupsdRemoveFile(oldfile) && errno != ENOENT) ||       (rename(filename, oldfile) && errno != ENOENT) ||       rename(newfile, filename))   {     cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to finalize \"%s\": %s",                     filename, strerror(errno));     return (-1);   }   return (0); } int /* O - 0 on success, -1 on error */ cupsdRemoveFile(const char *filename) /* I - File to remove */ { ...  /*   * Overwrite the file 7 times with 0xF6, 0x00, 0xFF, random, 0x00, 0xFF,   * and more random data.   */   memset(buffer, 0xF6, sizeof(buffer));   if (overwrite_data(fd, buffer, sizeof(buffer), (int)info.st_size))   {     close(fd);     return (-1);   } ... } static int /* O - 0 on success, -1 on error */ overwrite_data(int fd, /* I - File descriptor */                const char *buffer, /* I - Buffer to write */         int bufsize, /* I - Size of buffer */                int filesize) /* I - Size of file */ {   int bytes; /* Bytes to write/written */  /*   * Start at the beginning of the file...   */   if (lseek(fd, 0, SEEK_SET) < 0)     return (-1);  /*   * Fill the file with the provided data...   */   while (filesize > 0)   {     if (filesize > bufsize)       bytes = bufsize;     else       bytes = filesize;     if ((bytes = write(fd, buffer, bytes)) < 0)       return (-1);     filesize -= bytes;   }  /*   * Force the changes to disk...   */   return (fsync(fd)); } ---- indicator-printers-service.c ---- #define NOTIFY_LEASE_DURATION (15 * 60) int main (int argc, char *argv[]) { ...     g_timeout_add_seconds (NOTIFY_LEASE_DURATION - 60,                            renew_subscription_timeout,                            &subscription_id); ... }
2013-10-30 16:58:50 Till Kamppeter bug added subscriber Michael R Sweet
2013-10-30 17:37:35 Till Kamppeter bug task added indicator-printers (Ubuntu)
2013-10-30 17:48:15 Michael R Sweet attachment added str3715.patch https://bugs.launchpad.net/bugs/1244205/+attachment/3895920/+files/str3715.patch
2013-10-30 17:48:15 Michael R Sweet attachment added str3715p2.patch https://bugs.launchpad.net/bugs/1244205/+attachment/3895921/+files/str3715p2.patch
2013-10-30 17:48:15 Michael R Sweet attachment added str3715p3.patch https://bugs.launchpad.net/bugs/1244205/+attachment/3895922/+files/str3715p3.patch
2014-01-03 19:08:44 Till Kamppeter cups (Ubuntu): status New Won't Fix
2014-03-13 17:36:47 Launchpad Janitor branch linked lp:~larsu/indicator-printers/lp1244205
2014-03-13 22:47:51 Launchpad Janitor branch linked lp:ubuntu/trusty-proposed/indicator-printers
2014-03-13 23:24:35 Launchpad Janitor indicator-printers (Ubuntu): status New Fix Released
2015-06-25 06:23:20 Ken Sharp tags precise
2015-06-25 06:23:54 Ken Sharp ubuntu-power-consumption: status New Fix Released