-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mount r/w GCE PD disks with -o discard #28448
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,9 @@ func (attacher *gcePersistentDiskAttacher) MountDevice(spec *volume.Spec, device | |
options := []string{} | ||
if readOnly { | ||
options = append(options, "ro") | ||
} else { | ||
// as per https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting | ||
options = append(options, "discard") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the same documentation don't we also want to do this for mkfs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pkg/util/mount is used by more than GCE, and I don't know if that option should be used on real disks... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you just made me look at the kernel source code again. We should not run mkfs if we don't know that the device supports TRIM. You can see in fs/ext4/mballoc.c that if DISCARD is set but not supported in the device the kernel will emit a warning to dmesg, even just for mount. I think if we cannot test for SSD or discard supported device we should not set this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean we should not mount with trim if we did not mkfs with trim? On Wed, Jul 6, 2016 at 11:45 PM, Michael Rubin notifications@github.com
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I looked at it even deeper. enabling this in mkfs only speeds up mkfs, it has no fs impact once mounted. We get benefits of "discard" in the mount option. So we don't need to do both. |
||
} | ||
if notMnt { | ||
diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Runner: exec.New()} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to test for ext4 also. I don't think ext2 (nor implictly ext3 supports this mount option)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This just got complicated.
On Wed, Jul 6, 2016 at 11:51 PM, Michael Rubin notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thockin @saad-ali @ciwang Can't you just use "file -s"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thockin @saad-ali @ciwang Can't you just use "file -s"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd have to explain more what you're thinking.
On Thu, Jul 7, 2016 at 12:14 AM, Michael Rubin notifications@github.com
wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thockin @ciwang @saad-ali
Can we invoke file -s on the block device so that we can determine the filesystem type in a portable manner?
Check out: http://www.thegeekstuff.com/2011/04/identify-file-system-type/
This might be a good PR for ciwang's stack of intern items. Or does "file" not exist in our image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh! Yeah, we could, I'm just wary of too many "is ext4" conditionals
spread throughout the code makeing assumptions about what flags other parts
did or did not use.
On Thu, Jul 7, 2016 at 12:39 AM, Michael Rubin notifications@github.com
wrote: